All indicators

MACD Divergence V0

Aug 9, 2015

Static chart image
SignalsOscillatorsDivergences

The MACD Divergence V0 indicator is a momentum-based tool designed to automatically detect and highlight regular and hidden divergences between price action and the MACD histogram. By identifying these discrepancies, the script helps traders spot potential trend reversals or continuations that may not be immediately apparent through price action alone.

Usage

The indicator can be used to identify four distinct types of divergences:

  • Regular Bullish Divergence: Occurs when price makes a lower low but the MACD histogram makes a higher low, suggesting a potential upward reversal.
  • Regular Bearish Divergence: Occurs when price makes a higher high but the MACD histogram makes a lower high, suggesting a potential downward reversal.
  • Hidden Bullish Divergence: Occurs when price makes a higher low but the MACD histogram makes a lower low, suggesting trend continuation to the upside.
  • Hidden Bearish Divergence: Occurs when price makes a lower high but the MACD histogram makes a higher high, suggesting trend continuation to the downside.

Divergences are identified using a fractal-based lookback mechanism (5-bar window) and are plotted with labels and colored circles on the histogram for clear visualization.

Details

The script calculates the standard MACD using the difference between a Fast SMA and a Slow SMA, with an EMA applied for the signal line. To detect divergences, the tool employs a fractal function that identifies local peaks and troughs in the MACD histogram. Because the fractal logic requires a confirmation of two bars following the peak/trough, signals are plotted with an offset of -2 to align with the actual point of divergence.

Settings

  • Source: Determines the input data used for the MACD calculations (default is Close).
  • Fast Length: The period for the fast Simple Moving Average.
  • Slow Length: The period for the slow Simple Moving Average.
  • Signal Smoothing: The period for the Exponential Moving Average used to create the signal line.

FAQ

How do I interpret the labels on the chart?

The indicator plots "Regular" or "Hidden" labels at the top or bottom of the MACD histogram. Green labels indicate bullish divergence, while red labels indicate bearish divergence.

Why are the signals appearing two bars late?

The script uses a fractal-based detection method which requires two bars to the right of a peak or trough to confirm the pivot point. This ensures the validity of the divergence at the cost of a small lag.

How can I get access to MACD Divergence V0?

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.