Moving Average & Candle Colored
Apr 19, 2019

The Moving Average & Candle Colored indicator provides a dynamic Simple Moving Average (SMA) and candle coloring system designed to highlight trend direction and price positioning relative to the average. It serves as a visual aid for identifying momentum shifts and potential entry or exit points based on the relationship between price action and trend slope.
Usage
The Usage section describes how the script can be used to interpret market trends. The indicator applies color logic to both the moving average line and the individual price bars to provide a comprehensive view of market sentiment.
Trend Identification
The Simple Moving Average (SMA) changes color based on its slope. A green SMA indicates a positive slope (rising trend), while a red SMA indicates a negative slope (falling trend). If the slope is neutral, the line appears blue. Traders can use these color shifts to identify when a trend is gaining or losing momentum.
Price Positioning
The script recolors the chart's candlesticks based on their closing price relative to the SMA:
- Green Candles: Close price is above the SMA, suggesting bullish positioning.
- Red Candles: Close price is below the SMA, suggesting bearish positioning.
Signals and Alerts
The tool includes built-in alert logic for specific technical events:
- Price Crosses: Alerts trigger when price crosses above or below the SMA.
- Slope Changes: Alerts trigger the moment the SMA shifts from a downward to an upward slope, or vice versa.
Details
The script calculates a standard Simple Moving Average (SMA) based on a user-defined length. The coloring logic for the SMA is determined by comparing the current SMA value to its previous value (out > out[1]). The bar coloring logic is determined by comparing the current close to the current SMA value. By combining trend direction (slope) with price location (bar color), the script allows for quick visual filtering of trend-following setups.
Settings
- Show SMA on chart: Toggles the visibility of the Simple Moving Average line.
- SMA Length: Determines the number of periods used to calculate the Simple Moving Average. Increasing this value results in a smoother line that reacts more slowly to price changes, while decreasing it makes the indicator more sensitive to recent volatility.
FAQ
How do I use this indicator for entries and exits?
Traders typically look for "confluence" where both the SMA slope and the candle color align. For example, a green SMA combined with price crossing above it (turning the candles green) may signal a bullish entry.
Can I change the source of the SMA?
In this specific version, the SMA is calculated using the "Close" price. To use different price sources like Open, High, or Low, the script code would need to be adjusted.
How can I access the Moving Average & Candle Colored 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.