Extended from Moving Average
Jan 19, 2023

The Extended from Moving Average indicator identifies when price action has deviated significantly from a selected moving average to help traders avoid chasing overextended trends.
Usage
The Usage section describes how the script can be used to identify potential mean reversion or exhaustion points. Traders typically use this tool to determine if a trend is overstretched, suggesting that entering a position at the current price may carry higher risk.
Identifying Extension
When the percentage distance between the price and the moving average exceeds the user-defined threshold, the area between the price and the MA is highlighted.
- Price > MA: Highlights indicating the asset may be overbought or extended to the upside.
- Price < MA: Highlights indicating the asset may be oversold or extended to the downside.
Multi-Timeframe Analysis
The indicator allows users to select a specific timeframe for the moving average calculation. This enables traders to monitor extensions from daily or weekly moving averages while viewing a lower-timeframe chart.
Visual Feedback
The script provides a real-time table displaying the current percentage distance from the MA. Additionally, users can enable shapes (triangles) to appear on the chart when the "extended" condition is met to provide immediate visual alerts.
Details
The indicator calculates the absolute percentage difference between the current closing price and the selected moving average (SMA or EMA). This calculation is expressed as:
Distance % = |((Price / Moving Average) - 1) * 100|
The tool utilizes request.security to fetch the moving average data from the specified timeframe, ensuring the extension logic remains consistent regardless of the chart's current resolution. When the calculated distance surpasses the "Distance for Extended" input, the script triggers visual highlights and alert conditions.
Settings
Display Options
- Show Moving Average: Toggles the visibility of the moving average line on the chart.
- Show Shape Price > MA: Enables a downward triangle shape when the price is extended above the MA.
- Show Shape Price < MA: Enables an upward triangle shape when the price is extended below the MA.
- Highlight Distance Between MA: Toggles the background fill between the MA and the price during extended periods.
- Price > MA / Price < MA Colors: Customizes the colors for the highlights and shapes.
Moving Average & Price Settings
- MA Info: Selects the type of moving average (EMA or SMA) and the period length.
- Timeframe: Specifies the timeframe from which the moving average is calculated.
- Distance for Extended: Sets the percentage threshold required for the price to be considered "extended."
Distance Table
- Show Quartiles Table: Toggles the visibility of the info table.
- Table Position: Adjusts the vertical and horizontal placement of the data table.
- Text Size: Changes the scale of the text within the table.
FAQ
How do I adjust the sensitivity of the extension alerts? You can modify the "Distance for Extended" setting. A higher percentage will require a larger price move to trigger an alert, while a lower percentage will make the indicator more sensitive to minor deviations.
Can I use this for mean reversion strategies? Yes, many traders use the extension highlights as a signal that the price may return toward the moving average, though it is often used in conjunction with other technical indicators for confirmation.
How do I get access to the Extended from Moving Average indicator? You can get access on the LuxAlgo Library for charting platforms like TradingView, MetaTrader (MT4/MT5), and NinjaTrader for free.
Free indicator
Get free access to this indicator on the platforms below.
Unlock the entire LuxAlgo Library
Every indicator, every strategy, full charts, and complete access to Quant — our AI agent.