MACD Potential Divergence
Jul 11, 2022

The MACD Potential Divergence indicator provides an advanced momentum analysis tool that identifies both early-stage "potential" and fully confirmed divergences on the MACD histogram. By signaling divergences before they are fully confirmed by traditional pivot lookbacks, this tool aims to provide earlier entries into potential trend reversals or continuations.
Usage
The Usage section highlights how to interpret the different labels and signals provided by the indicator:
- Potential Divergences: Indicated by the letter "B" (for regular) or "H" (for hidden). These appear in real-time when the price and MACD momentum begin to deviate, allowing traders to prepare for a possible setup before the pivot point is fully aged.
- Confirmed Divergences: These appear as labels marked "Bull", "Bear", "H Bull", or "H Bear" accompanied by a connecting line. These signals are confirmed once the price has moved sufficiently to establish a swing high or low based on the lookback settings.
- Bullish Divergence (Green): Suggests a potential upward reversal when the price makes a lower low but the MACD histogram makes a higher low.
- Bearish Divergence (Red): Suggests a potential downward reversal when the price makes a higher high but the MACD histogram makes a lower high.
Details
The script calculates divergences based on the MACD histogram (the difference between the MACD line and the Signal line). Unlike standard divergence indicators that only plot after a pivot is confirmed (often lagging by several bars), this script utilizes a "potential" logic. It monitors momentum expansion and contraction in real-time to alert users when the conditions for a divergence are currently being met, even if the required "right-side" lookback for a pivot hasn't been completed yet. This allows for a more proactive approach to momentum trading.
Settings
MACD 30 9
- Fast Length: The period for the shorter moving average (default is 12).
- Slow Length: The period for the longer moving average (default is 26).
- Source: The price data used for calculations (default is close).
- Signal Smoothing: The period for the Signal line moving average.
- Oscillator MA Type: Choose between SMA or EMA for the MACD calculation.
- Signal Line MA Type: Choose between SMA or EMA for the Signal line calculation.
Div Settings
- Show Divergence: Toggles the visibility of all divergence elements.
- Pivot Lookback Right/Left: Sets the number of bars required to confirm a swing high or low.
- Max/Min of Lookback Range: Defines the distance between two peaks/troughs to be considered for a divergence.
- Plotting Toggles: Individual checkboxes to enable or disable Regular, Hidden, and Potential variations of Bullish and Bearish signals.
FAQ
How do I interpret the "B" label versus the "Bull" label? The "B" label signifies a "Potential" divergence that is currently forming, while the "Bull" label signifies a "Confirmed" divergence that has met the pivot lookback requirements.
Can I change the sensitivity of the divergence detection? Yes, by adjusting the "Pivot Lookback" and "Lookback Range" settings, you can make the indicator more or less sensitive to price swings.
How can I access MACD Potential Divergence? 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.