Skip to content

Free MT5 indicator

RSI Divergence

RSI with overbought and oversold levels for MT5 that marks regular and hidden divergences with arrows, lines and alerts.

Momentumv1.0MetaTrader 5 (MQL5) Compiles with 0 errors Non-repainting signals Alerts

What it does

RSI Divergence plots the Relative Strength Index in its own window with overbought, midline and oversold levels, and automatically marks divergences between RSI and price. Each divergence gets a line joining the two RSI pivots, an arrow on the newer pivot and an optional matching line on the price chart.

Solid lines are regular divergences and dashed lines are hidden divergences. Bullish marks are green and bearish marks are red.

How it works

  1. RSI is read from MetaTrader's built-in RSI (Wilder smoothing) with the chosen length and applied price.
  2. A pivot low is a bar whose RSI is lower than each of the 5 bars before it and not higher than each of the 3 bars after it. Pivot highs are the mirror image. The pivot is only tested after the third bar to the right has closed.
  3. When a new pivot is confirmed, it is compared with the previous pivot of the same type if the gap is between 5 and 60 bars:
    • Regular bullish: lower low in price, higher low in RSI.
    • Hidden bullish: higher low in price, lower low in RSI.
    • Regular bearish: higher high in price, lower high in RSI.
    • Hidden bearish: lower high in price, higher high in RSI.
  4. Price is measured with the bar's low for pivot lows and the bar's high for pivot highs.

How to use it

  • Regular bullish divergence near or below the oversold level, and regular bearish divergence near or above overbought, are the classic exhaustion patterns.
  • Hidden divergences are continuation clues: in an uptrend, a hidden bullish mark during a pullback suggests momentum reset without the trend breaking.
  • Wait for price to confirm, for example a close back above a minor swing high after a bullish mark, before treating it as a setup.
  • Divergences on higher timeframes carry more weight than those on M1 or M5.
  • The RSI Indicator lesson explains the oscillator itself.

Settings

InputDefaultWhat it changes
RSI length14Sensitivity of the RSI line
Applied priceClosePrice fed into the RSI
Overbought / oversold level70 / 30Reference levels only; they do not filter divergences
Pivot bars left / right5 / 3Pivot strictness and confirmation delay
Minimum / maximum bars between pivots5 / 60Which pivot pairs are compared
Show regular / hiddentrue / trueToggle each family
Draw lines on the price charttrueMirrors each divergence on price
Pop-up alert / Push notificationfalse / falseOne alert when a new divergence is confirmed

Limitations

  • Every mark is delayed by the right-hand pivot bars (3 by default). The arrow is drawn back on the pivot bar once confirmed and does not move afterwards, but it was not visible in real time at that bar.
  • In strong trends RSI can stay overbought or oversold and print repeated divergences while price keeps going.
  • Small pivot settings create many marks, including minor ones of little value.
  • The RSI on the live bar changes with each tick.
  • Divergence is an educational analysis aid, not a trade signal on its own. Trading involves substantial risk of loss.

Key inputs

Key inputs of RSI Divergence
InputDefaultDescription
RSI length14Period of the Relative Strength Index.
Applied priceClosePrice used for the RSI calculation.
Overbought / oversold level70 / 30Horizontal reference levels in the RSI window.
Pivot bars to the left5Bars before a pivot that must be less extreme.
Pivot bars to the right (confirmation delay)3Bars after a pivot that must close before it is confirmed.
Minimum / maximum bars between pivots5 / 60Allowed distance between the two pivots being compared.
Show regular / hidden divergencestrue / trueTurns each divergence family on or off.

Educational tools, not advice. Indicators and Expert Advisors describe price; they do not predict it, and past behaviour does not guarantee future results. Test everything on a demo account first and never risk money you cannot afford to lose. See our disclaimer.

Keep exploring

Related mt5 indicators