Moving average Two Colours
Sep 3, 2018

The Moving average Two Colours indicator provides a visual trend-following tool that automatically changes the EMA's color based on whether the price is trading above or below the average to signal market sentiment.
Usage
The Usage section describes how the script can be used to identify market trends and potential reversal points. Traders utilize this indicator to establish a directional bias; for example, a green EMA suggests a bullish environment where the price is holding above the average, while a red EMA indicates bearish pressure with the price trading below it.
Examples of usage include:
- Trend Identification: Using the default 200-period setting to determine the long-term trend on daily or hourly charts.
- Support and Resistance: Monitoring how price interacts with the EMA line when the color shifts, often indicating a transition in market control.
- Alerting: The script includes built-in alert conditions that trigger when the price crosses over or under the EMA, allowing traders to react to trend changes in real-time.
Details
The script calculates an Exponential Moving Average (EMA) based on a user-defined length and price source. Unlike a standard Simple Moving Average, the EMA places a greater weight on the most recent data points, making it more responsive to recent price action.
The core logic of the script compares the close price of the current bar to the emaValue. If the price is higher than the EMA, the plot is assigned a green color. If the price is lower than the EMA, it is assigned a red color. This color-coded output simplifies technical analysis by removing the need to manually check price levels against the indicator value.
Settings
- Length: Sets the lookback period for the Exponential Moving Average calculation. Higher values create a smoother, slower-moving line.
- Source: Determines which price data point from each candle is used for the calculation (e.g., Close, Open, High, Low).
FAQ
What timeframe is best for this indicator? The indicator can be applied to any timeframe. Higher timeframes like the Daily or 4-hour are typically used with the default 200-period setting to identify major trends, while lower timeframes are used for intraday momentum.
Can I change the colors of the EMA? Yes, while the script defaults to green and red to represent bullish and bearish states, the colors and line thickness can be adjusted within the style settings of the charting platform.
How do I access the Moving average Two Colours 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.