All indicators

MACD Divergence H/R

Aug 23, 2021

Static chart image
SignalsOscillatorsDivergencesMoving Averages

The MACD Divergence H/R indicator identifies regular and hidden divergences between the price action and the MACD histogram to highlight potential trend reversals and continuations. By analyzing the relationship between price extremes and histogram peaks/troughs across consecutive cycles, this tool automates the detection of complex momentum shifts.

Usage

The Usage section focuses on identifying four specific types of momentum discrepancies. When a divergence is detected, the script plots a label on the MACD histogram and triggers an alert.

  • Regular Bullish (R_Bull): Occurs when the price makes a higher low while the MACD histogram makes a lower low. This suggests a potential reversal from a downtrend to an uptrend.
  • Hidden Bullish (H_Bull): Occurs when the price makes a lower low while the MACD histogram makes a higher low. This often indicates trend continuation.
  • Regular Bearish (R_Bear): Occurs when the price makes a lower high while the MACD histogram makes a higher high. This suggests a potential reversal from an uptrend to a downtrend.
  • Hidden Bearish (H_Bear): Occurs when the price makes a higher high while the MACD histogram makes a lower high. This often indicates a continuation of a bearish trend.

Details

The script functions by tracking the highest and lowest points of the MACD histogram during its positive (green) and negative (red) cycles. It compares these values against the price's high or low during those same periods.

To filter out insignificant market noise, the indicator utilizes a "Minimum Value Required" threshold. A divergence is only validated if the histogram peaks or troughs exceed this user-defined value, ensuring that only significant momentum shifts are flagged. The labels are pinned to the specific historical bar where the divergence was confirmed.

Settings

MACD Settings

  • Fast Length: The period for the shorter moving average used in MACD calculation (default 12).
  • Slow Length: The period for the longer moving average used in MACD calculation (default 26).
  • Source: The price data used for the calculation (default: close).
  • Signal Smoothing: The period for the signal line EMA (default 9).

Filtering

  • Histograms Minimum Value Required: Sets the minimum absolute value the MACD histogram must reach to qualify a peak or trough for divergence detection.

Visuals

  • H_Bull / R_Bull / R_Bear / H_Bear Text: Customizes the text displayed on the chart for each divergence type.
  • H_Bull / R_Bull / R_Bear / H_Bear Color: Customizes the label and signal colors for better chart organization.

FAQ

How do I use the MACD Divergence H/R indicator?

You can use it to spot potential entries or exits by watching for labels on the histogram. Regular divergences typically suggest reversals, while hidden divergences suggest the current trend may continue.

What is the difference between regular and hidden divergence?

Regular divergence signals a potential trend reversal by showing a exhaustion in momentum, whereas hidden divergence signals trend continuation by showing momentum is stronger than price suggests.

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.