All indicators

MACD with Directional Colors

Jun 3, 2018

Static chart image
SignalsOscillatorsMoving Averages

The MACD with Directional Colors indicator provides a visual momentum tracking system that dynamically colors components based on their directional slope to identify trend shifts more efficiently.

Usage

The Usage section describes how the script can be used to interpret market momentum and trend changes.

  • Trend Direction: The indicator colors both the MACD and Signal lines based on their current trajectory. A green color indicates the line is sloping upward (increasing value), while a red color indicates it is sloping downward (decreasing value). This allows traders to spot momentum shifts before a crossover occurs.
  • Crossover Signals: Bullish and bearish crossovers are highlighted with plot shapes. A green up-arrow appears when the MACD line crosses above the Signal line, while a red down-arrow appears when the MACD line crosses below the Signal line.
  • Histogram Interpretation: In this version, the histogram represents the MACD line itself rather than the difference between the MACD and Signal lines. This helps in visualizing the absolute strength and distance of the MACD from the zero median.
  • Alerts: The script includes optimized alerts for crossover events, allowing users to be notified when the MACD crosses the Signal line in either direction.

Details

The MACD with Directional Colors is based on the traditional Moving Average Convergence Divergence framework originally developed by Gerald Appel, with refactored logic for directional coloring.

The calculation follows these steps:

  1. MACD Line: Subtracting the Slow Exponential Moving Average (EMA) from the Fast EMA.
  2. Signal Line: Calculating an EMA of the resulting MACD line.
  3. Directional Logic: The script compares the current bar's value ($x$) to the previous bar ($x[1]$). If $x > x[1]$, the momentum is considered upward (Green); if $x < x[1]$, it is considered downward (Red).
  4. Visual Refinement: By replacing the standard delta-based histogram with a directional MACD-line histogram, the indicator emphasizes the velocity of the primary trend component.

Settings

  • Fast Length: Defines the period for the shorter-term Exponential Moving Average (default is 12).
  • Slow Length: Defines the period for the longer-term Exponential Moving Average (default is 26).
  • Signal Length: Defines the smoothing period for the EMA applied to the MACD line to create the Signal line (default is 9).

FAQ

What do the green and red colors on the lines represent? The colors indicate the slope of the lines. Green means the value is currently rising compared to the previous bar, while red means the value is falling.

How does this differ from a standard MACD? While the core calculations are the same, this version removes the traditional histogram (the difference between MACD and Signal) and instead uses a histogram style for the MACD line itself, while adding directional color-coding to all components.

How can I access this tool? 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.

TradingView
NinjaTrader
MetaTrader 4/5

Unlock the entire LuxAlgo Library

Every indicator, every strategy, full charts, and complete access to Quant — our AI agent.