Indicator - MACD w/ 4 Color Histogram
Feb 9, 2014

The Indicator - MACD w/ 4 Color Histogram tool provides a visually enhanced Moving Average Convergence Divergence oscillator designed to help traders quickly identify trend momentum and potential reversals through a color-coded histogram.
Usage
The Usage section describes how the script can be used to interpret market momentum. The primary focus of this indicator is the 4-color histogram, which provides more granular information than a standard two-color histogram.
- Dark Green: Indicates the histogram is above the zero line and increasing in value (bullish momentum strengthening).
- Light Green: Indicates the histogram is above the zero line but decreasing in value (bullish momentum weakening).
- Dark Red: Indicates the histogram is below the zero line and decreasing in value (bearish momentum strengthening).
- Light Red: Indicates the histogram is below the zero line but increasing in value (bearish momentum weakening).
Traders can use these color transitions to anticipate potential trend exhaustion or the start of a new trend before the MACD and Signal lines actually cross.
Details
This script is a refactored version of the classic MACD (Moving Average Convergence Divergence) indicator. It calculates the difference between a Fast EMA and a Slow EMA to create the MACD line. A Signal line (SMA of the MACD) is then calculated. The histogram represents the distance between the MACD line and the Signal line.
The unique aspect of this implementation is the logic applied to the hist variable:
- It compares the current histogram value to its previous value (
hist[1]). - It checks the position relative to the zero line.
- This results in four distinct states that allow for the 4-color visual representation.
Settings
- Fast Length: The period for the shorter Exponential Moving Average (default is 12).
- Slow Length: The period for the longer Exponential Moving Average (default is 26).
- Signal Length: The smoothing period for the Signal line calculation (default is 9).
- Source: The price data used for the calculations (typically set to 'close').
FAQ
How do I interpret the light-colored histogram bars? Light green or light red bars indicate "fading" momentum. This occurs when the histogram is moving back toward the zero line, suggesting that the current trend may be losing strength.
Can I set alerts for crossovers? Yes, the script includes built-in alert functionality for when the MACD line crosses above or below the Signal line, which are common entry and exit signals.
How can I access this 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.