Learn
Divergence 2 min read

Divergence Detector

Early warning that the existing trend is losing fuel.

Finds moments when price prints a new extreme but RSI and MACD do not — classic early reversal signal.

The idea

Trends end when the people driving them run out of money or conviction. That exhaustion shows up in momentum indicators before it shows up in price. By the time the chart breaks down, RSI has already been sliding lower for weeks.

Divergence Detector automates the pattern recognition: for every bar, it looks back 20 bars, finds the lowest low (for bullish setups) and highest high (for bearish setups), and compares the momentum readings at those extremes with the current reading.

Signal types

LabelMeaningStrength
Bull Div (RSI)Price new low, RSI higher lowNormal
Bull Div (MACD)Price new low, MACD histogram higherNormal
Bull Div (RSI+MACD)Both agreeStrong
Bear Div (RSI)Price new high, RSI lower highNormal
Bear Div (MACD)Price new high, MACD histogram lowerNormal
Bear Div (RSI+MACD)Both agreeStrong

Signals respect an 8-bar cooldown to avoid clustering.

How to use it

  1. Enable Divergence Detector in the Scripts panel. Markers appear under or above the candle that completed the divergence.
  2. Treat the signal as permission to look for a trade, not a trade itself. Wait for price action confirmation — a break of the last minor swing, a reversal candle, a retest of a key level.
  3. Strong signals (RSI+MACD) are worth paying attention to even in trending markets. Weak single-indicator signals need extra context.

Why divergences work (and when they fail)

In a typical cycle, the final push higher is driven by late buyers chasing momentum. They pay more but generate less follow-through, so the oscillator can't keep up with price. Eventually the marginal buyer runs out and the trend reverses.

The mode that breaks this is a parabolic blowoff. In that regime, divergences form and persist for a long time without resolving. If you see three or four stacked bearish divergences that keep getting invalidated, you are likely in a blowoff — step aside and wait for the break.

Frequently asked

What exactly is a divergence?
A mismatch between price direction and momentum. Price makes a new low but RSI does not → bullish (hidden strength). Price makes a new high but RSI does not → bearish (hidden weakness).
Why both RSI and MACD?
RSI is faster and prone to false signals. MACD is slower and more reliable. When both disagree with price at the same time, the probability of reversal is meaningfully higher.
How soon after the signal does the reversal happen?
Minutes on scalping timeframes, days to weeks on higher timeframes. Divergence is a *condition*, not a trigger — use structure and candle confirmation for timing.