MACD Price Divergence indicator
Jun 30, 2019

The MACD Price Divergence indicator identifies discrepancies between price action and MACD momentum to highlight potential trend reversals or exhaustions. It automatically detects and plots bullish and bearish divergence lines directly on the price chart, providing clear visual cues for mean reversion opportunities.
Usage
The indicator can be used to identify high-probability reversal zones where the price momentum (MACD) is no longer supporting the current price trend.
- Bullish Divergence (🐂): Occurs when the price makes a lower low, but the MACD line makes a higher low. This suggests that despite the downward price movement, selling pressure is decreasing. An arrow up and a green line connecting the lows will appear on the chart.
- Bearish Divergence (🐻): Occurs when the price makes a higher high, but the MACD line makes a lower high. This indicates that upward momentum is slowing down even as prices rise. An arrow down and a red line connecting the highs will appear on the chart.
Traders often use these signals as a confirmation for existing reversal strategies or as an early warning to tighten stop-losses on current positions.
Details
The script utilizes pivot point logic (lows and highs) to anchor the divergence lines. It calculates divergences based on the standard MACD (12, 26, 9) settings. A unique filtering mechanism is included to ensure the quality of the signal: the slope of the divergence line (the trendline connecting price peaks or troughs) must not be violated by intervening price action. This ensures that the divergence is "clean" and hasn't been invalidated by price spikes between the two points.
Settings
Bullish Settings
- Max lookback for bullish lowest low pivot point: Sets the maximum number of bars to look back to find the most recent pivot low.
- Max lookback bullish for divergence: Sets the maximum search distance between the current pivot low and a previous pivot low to establish a divergence.
Bearish Settings
- Max lookback for bearish highest high pivot point: Sets the maximum number of bars to look back to find the most recent pivot high.
- Max lookback bearish for divergence: Sets the maximum search distance between the current pivot high and a previous pivot high to establish a divergence.
FAQ
How do I use the MACD Price Divergence signals?
The signals are typically used to anticipate potential market reversals. A bullish signal suggests a potential upward turn, while a bearish signal suggests a potential downward turn.
Does the indicator repaint?
The indicator uses pivot points with a right-bar offset (confirmation bars). While the lines and shapes appear after a short delay (2 bars) to confirm the pivot, they do not change position once the confirmation candle has closed.
How can I access this tool on other platforms?
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.