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.
Trading & investing are risky and many will lose money in connection with trading and investing activities. All content on this site is not intended to, and should not be, construed as financial advice. Decisions to buy, sell, hold or trade in securities, commodities and other investments involve risk and are best made based on the advice of qualified financial professionals. Past performance does not guarantee future results.
Hypothetical or Simulated performance results have certain limitations. Unlike an actual performance record, simulated results do not represent actual trading. Also, since the trades have not been executed, the results may have under-or-over compensated for the impact, if any, of certain market factors, including, but not limited to, lack of liquidity. Simulated trading programs in general are designed with the benefit of hindsight, and are based on historical information. No representation is being made that any account will or is likely to achieve profit or losses similar to those shown.
Testimonials appearing on this website may not be representative of other clients or customers and is not a guarantee of future performance or success.
As a provider of technical analysis tools and strategies, we do not have access to the personal trading accounts or brokerage statements of our customers. As a result, we have no reason to believe our customers perform better or worse than traders as a whole based on any content, tool, or platform feature we provide.
Charts used on this site are by TradingView in which the majority of our technical indicators are built on. TradingView® is a registered trademark of TradingView, Inc. www.TradingView.com TradingView® has no affiliation with the owner, developer, or provider of the Services described herein.
Market data is provided by CBOE, CME Group, BarChart, Massive, CoinAPI. Select U.S. equities data is provided through Massive. CBOE BZX real-time U.S. equities data is licensed from CBOE and provided through BarChart. Real-time futures data is licensed from CME Group and provided through BarChart. Select cryptocurrency data, including major coins, is provided through CoinAPI. All data is provided “as is” and should be verified independently for trading purposes.
This does not represent our full Disclaimer. Please read our full disclaimer.
© 2026 LuxAlgo Global, LLC.

