Divergence describes a disagreement between price movement and a momentum oscillator such as RSI, MACD, or the Stochastic. This educational guide explains what divergence is, the common regular and hidden types, how traders typically interpret it, its well-known weaknesses, and a short, valid Pine Script v6 example. It is for education only and is not buy or sell advice. No indicator predicts the future, and all trading carries risk of loss.
Divergence is a disagreement between what price is doing and what a momentum indicator is doing over the same set of swings. For example, price may print a higher high while an oscillator such as RSI prints a lower high. Because these oscillators are derived from price (RSI and MACD are calculated from closing prices, while the Stochastic is calculated from the high-low range and the close), a divergence is really a statement about momentum: price reached a new extreme, but the underlying rate of change behind that move was weaker than before.
It is worth being precise about the comparison. A divergence is defined between two pivots of the same kind, two swing highs or two swing lows, not between arbitrary points. Traders read the slope of the line connecting the two price pivots against the slope of the line connecting the corresponding indicator pivots. When those slopes disagree, that is divergence. This is a description of what has already happened on the chart, not a prediction of what will happen next.
Regular (sometimes called "classic") divergence is the most commonly discussed form. Regular bearish divergence is when price makes a higher high but the indicator makes a lower high. Regular bullish divergence is when price makes a lower low but the indicator makes a higher low. Traders often describe regular divergence as a possible sign that the current move is losing momentum, though it does not tell you whether or when a turn will occur.
Hidden divergence reverses which side makes the larger extreme and is usually discussed in the context of a trend continuing. Hidden bullish divergence is when price makes a higher low but the indicator makes a lower low; hidden bearish divergence is when price makes a lower high but the indicator makes a higher high. Traders often interpret hidden divergence as information consistent with the prevailing trend rather than against it. In every case these are interpretations and context, not signals to act on.
Divergence can be measured against any momentum oscillator, but a few are conventional. RSI (Relative Strength Index) is widely used because its pivots are easy to compare against price pivots. MACD is also common; traders may compare price against either the MACD line or its histogram. The Stochastic oscillator is another frequent choice.
The indicator you choose changes what you see, because each is calculated differently and reacts to price at a different speed. A divergence visible on one oscillator may not appear on another over the same swings. There is no single "correct" indicator for divergence, and the same chart can show conflicting readings depending on the tool and its settings. None of these tools forecasts price; they simply summarize past price behavior in different ways.
Divergence is descriptive rather than predictive. A key limitation is that divergence can persist far longer than expected: a strong trend can keep making new highs while the indicator keeps weakening, and price may simply continue. Traders sometimes summarize this as "divergence is not a timing tool."
There are other well-known pitfalls. A divergence can resolve through sideways consolidation instead of a reversal, so the momentum disagreement is "worked off" without a notable price move. Readings are also sensitive to how swing pivots are detected; shifting the lookback or the timeframe can make a divergence appear or disappear. Because of this, many traders treat divergence as one piece of context, considered alongside market structure, trend, and a defined risk plan, rather than as a standalone reason to enter or exit. This is not advice to trade in any particular way. No indicator forecasts price, and all trading carries the risk of loss.
The snippet below is a minimal, valid Pine Script v6 example for educational purposes. It plots RSI and uses ta.pivothigh and ta.pivotlow to mark swing pivots, which are the points a trader would visually compare against price pivots when studying divergence. It does not generate buy or sell signals, does not detect divergence automatically, and is not advice.
//@version=6
indicator("RSI with pivot markers (educational)", overlay = false)
len = input.int(14, "RSI length")
leftBars = input.int(5, "Pivot left bars")
rightBars = input.int(5, "Pivot right bars")
r = ta.rsi(close, len)
plot(r, "RSI", color = color.blue)
hline(70, "Upper", color = color.gray)
hline(30, "Lower", color = color.gray)
ph = ta.pivothigh(r, leftBars, rightBars)
pl = ta.pivotlow(r, leftBars, rightBars)
plotshape(not na(ph), "RSI pivot high", style = shape.triangledown, location = location.top, color = color.red, size = size.tiny)
plotshape(not na(pl), "RSI pivot low", style = shape.triangleup, location = location.bottom, color = color.green, size = size.tiny)The markers appear with a delay of rightBars because a pivot is only confirmed after enough bars have formed to its right. To study divergence you would compare the indicator pivots this script marks against the corresponding price pivots on the chart yourself; the script does not assert that any divergence is present, does not predict price, and does not suggest that you should act on anything it shows. As with any tool, all trading carries the risk of loss.
Educational only — not financial advice. Trading involves substantial risk of loss.