What it does
MACD Divergence shows the MACD line, its signal line and a histogram in a separate window, and looks for disagreements between price and momentum. When it finds one it draws a line between the two oscillator pivots, places an arrow on the newer pivot and, if you like, draws a matching line on the price chart.
It detects four patterns: regular bullish, hidden bullish, regular bearish and hidden bearish. Regular divergences are drawn with solid lines and hidden ones with dashed lines.
How it works
- MACD = EMA(12) − EMA(26) of the close. Signal = EMA(9) of MACD. Histogram = MACD − signal.
- The histogram uses four colours: strong green when positive and rising, light green when positive and falling, strong red when negative and falling, light pink when negative and rising.
- A pivot low is a bar whose oscillator value is lower than the 5 bars before it and not higher than the 3 bars after it. A pivot high is the mirror image. A pivot is only confirmed once those 3 later bars have closed.
- Each new pivot is compared with the previous pivot of the same type if they are between 5 and 60 bars apart:
- Regular bullish: price makes a lower low, MACD makes a higher low.
- Hidden bullish: price makes a higher low, MACD makes a lower low.
- Regular bearish: price makes a higher high, MACD makes a lower high.
- Hidden bearish: price makes a lower high, MACD makes a higher high.
How to use it
- Regular divergence suggests momentum is fading in the current move and is often studied near the end of a trend.
- Hidden divergence suggests a pullback has stretched momentum without breaking price structure, and is often studied as trend continuation.
- Divergence describes momentum, not timing. Many traders wait for a trigger after the mark, such as a histogram colour change or a break of a minor swing.
- Divergences that form at clear support and resistance levels deserve more attention than those in open space.
- Learn the underlying indicator in MACD Indicator.
Settings
| Input | Default | What it changes |
|---|---|---|
| Fast / slow / signal EMA | 12 / 26 / 9 | The MACD itself |
| Oscillator used for pivots | MACD line | Histogram pivots are more frequent and more sensitive |
| Pivot bars left / right | 5 / 3 | Pivot strictness; more right bars means later but steadier marks |
| Minimum / maximum bars between pivots | 5 / 60 | Which pivot pairs are compared |
| Show regular / hidden divergences | true / true | Toggle each family |
| Draw lines on the price chart | true | Mirrors the divergence on price |
| Pop-up alert / Push notification | false / false | One alert when a new divergence is confirmed |
Limitations
- Marks are delayed. A divergence can only be confirmed after the pivot's right-hand bars close, so the arrow appears 3 bars (by default) after the bar it is drawn on. Once drawn it does not move or disappear.
- Divergence can persist through a strong trend, producing several marks before any reversal, or none at all.
- Results depend heavily on the pivot settings; there is no universally correct value.
- The MACD values on the live bar change with every tick.
- Treat every mark as a prompt for analysis, not an instruction to trade. Trading involves substantial risk of loss.

