Color Changing Moving Average
Oct 2, 2022

The Color Changing Moving Average indicator provides a trend-following visual tool that dynamically colors a moving average based on its calculated slope angle to help traders identify trend direction and momentum shifts.
Usage
The Color Changing Moving Average is used to distinguish between bullish and bearish market phases by observing the color of the plotted line. When the moving average angle is positive, the line turns green (or the designated "up" color), signaling upward momentum. When the angle is negative, the line turns red, signaling downward momentum.
Traders can utilize this script to:
- Identify trend reversals as the line changes color.
- Filter trades by only taking long positions when the moving average is green and short positions when it is red.
- Customize the sensitivity of the trend detection by adjusting the angle period and ATR settings.
The "Use EMA?" toggle allows users to switch between a smoother Exponential Moving Average and a standard Simple Moving Average, depending on their preference for reactivity versus stability.
Details
The script determines the color of the line by calculating the angle of the moving average over a specified lookback period. To ensure the angle calculation remains consistent across different assets and timeframes, it uses the Average True Range (ATR) as a normalization factor. The formula converts the price change relative to the ATR into radians and subsequently into degrees using the arctangent function.
This technical implementation is inspired by the angle calculation methods established by Mango2Juice and the dynamic coloring techniques demonstrated by zathura643. By normalizing the price movement with ATR, the angle remains relevant regardless of whether the asset is high-priced (like Bitcoin) or low-priced (like penny stocks).
Settings
- Angle Period: Defines the number of bars used to calculate the slope/angle of the moving average.
- ATR Period: Sets the lookback period for the Average True Range used to normalize the angle calculation.
- Angle Level: A threshold setting used to determine the significance of the slope (note: in this version, the color triggers on a cross of 0).
- Length: The period used for the underlying EMA or SMA calculation.
- Source: The price data used for the moving average calculation (defaults to "Close").
- Offset: Shifts the moving average plot forward or backward on the horizontal axis.
- Use EMA?: When enabled, the script calculates an Exponential Moving Average; when disabled, it uses a Simple Moving Average.
FAQ
How do I interpret a color change? A change from red to green indicates that the slope of the moving average has turned positive, suggesting the start of an uptrend. Conversely, a change from green to red indicates a negative slope and a potential downtrend.
Can I use this for scalping or swing trading? Yes, by adjusting the "Length" and "Angle Period" settings, you can tune the indicator for fast-paced scalping on lower timeframes or broader trend following on daily or weekly charts.
How can I access the Color Changing Moving Average? You can get access on the LuxAlgo Library for charting platforms like TradingView, MetaTrader (MT4/MT5), and NinjaTrader for free.
Unlock Unlimited Access to the LuxAlgo Library
Upgrade your plan to get all indicators, strategies, charts, and full access to Quant, our AI agent.
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.

