XAUUSD5mRSI Divergence
Free · open-sourceRSI Divergence

RSI Divergence Entry Engine

A line between two RSI pivots is a drawing. What you need is the rest of the trade.

The idea

Confirmed pivots, divergence in both panes, an optional trend filter, and an ATR trade model with three targets — all open-source.

Free & open-source · All markets, all timeframes · Divergence confirmed on bar close; pivots require right-side bars, so visuals are placed back at the historical pivot and were not available live on that candle · Dashboard statistics come from the script's own bar-touch model — not broker fills, not Strategy Tester results, and no performance guarantee.

RSI DivergenceCategory
RSI Divergence · ATR Trade MappingStyle
XAUUSD, ForexMarkets
All timeframesTimeframes
Free · open-sourceAccess
What it does

An open-source, pivot-confirmed RSI divergence engine. Regular bullish and bearish divergence is confirmed between RSI pivots and their matching price pivots, drawn in the RSI pane with a filled divergence area and on the price chart as a three-layer neon line. An optional trend filter (EMA 200, Supertrend, or higher-timeframe EMA 200) decides whether a divergence is allowed to open a tracked trade — Entry at the confirmation close, ATR stop, TP1 / TP2 / TP3 at your chosen 1R–7R target, one trade at a time, with persistent history, an R-based dashboard and alerts.

RSI divergence is easy to see after the fact and hard to act on live. Most divergence tools stop at the drawing: a line between two oscillator pivots, no answer on whether the broader trend supports the reversal, where a volatility-adjusted stop belongs, what the targets are, or how the same read has resolved historically. So the signal exists, but the trade never gets defined.

RSI Divergence Entry Engine takes the read to the end. RSI 14 pivots are confirmed with right-side bars (Pivot Lookback and Confirmation Bars are yours to set), and only a pivot pair between 5 and 60 bars apart qualifies. Regular bullish divergence needs a higher RSI low against a lower price low; bearish needs a lower RSI high against a higher price high. The confirmed divergence appears twice — inside the RSI pane, with the region between the RSI path and its straight reference filled in, and on the price chart as a three-layer neon line joining the corresponding price pivots.

The trend filter is deliberately separated from detection: Off, EMA 200, Supertrend (ATR 10, factor 3.0) or higher-timeframe EMA 200 governs whether a confirmed divergence is allowed to open a tracked trade, while the divergence visual stays regardless. Accepted setups open at the confirmation candle's close with an ATR × 2.0 stop, TP1 and TP2 at one-third and two-thirds of the selected 1R–7R TP3, one active trade at a time and TP3 / SL checks starting on the next candle — when both are touched in one candle, the stop wins. Completed trades keep their boxes and planned TP prices on the chart, and the dashboard reports closed trades, win rate, net R, average R and profit factor. Open-source and free.

What you get out of it
  • See regular bullish and bearish divergence confirmed, not guessed
  • Read the same divergence in the RSI pane and on the price chart
  • Choose how much confirmation delay you accept (pivot lookback + bars)
  • Filter entries by EMA 200, Supertrend or higher-timeframe trend — or not at all
  • Get Entry, ATR stop and TP1 / TP2 / TP3 mapped for every accepted setup
  • Keep one tracked trade at a time so the record stays clean
  • Review completed trades with persistent boxes and planned target prices
  • Free & open-source — inspect and adapt every line of the logic
Best for

Traders who already read RSI divergence and want it confirmed, filtered, mapped to risk and reviewable

Inside the engine

8 components, one output

Pivot-confirmed divergence

RSI 14 pivots with adjustable Pivot Lookback and Confirmation Bars, restricted to pivot pairs 5–60 bars apart, accepted only on a confirmed bar.

Two-pane visualization

A divergence line and filled area between the RSI path and its reference inside the pane, plus a three-layer neon line joining the matching price pivots on the chart.

Context separated from entries

The trend filter never hides a divergence — it only decides whether the trade engine accepts it, so you can study every structure and the filtered subset side by side.

Four trend-filter modes

Off, chart EMA 200, Supertrend (ATR 10, factor 3.0), or higher-timeframe close against its EMA 200 (default 4H), with the active reference drawn on the chart.

ATR risk mapping

Stop distance is ATR × your multiplier (default 2.0), so risk scales with current volatility instead of a fixed price distance.

Three-target model

TP3 selectable 1R–7R with TP1 and TP2 placed automatically at one-third and two-thirds; only TP3 counts as a win, SL counts as −1R.

Conservative exit handling

One tracked trade at a time, checks start the candle after entry, and when TP3 and SL fall inside the same candle the stop takes priority.

History + dashboard + alerts

Completed trade boxes and planned TP1/TP2/TP3 labels persist; the dashboard shows status, closed trades, win rate, net R, gross P/L, average R and profit factor, with separate alerts and one combined alert() workflow.

How to use it

From a blank chart to a read

  1. Add RSI Divergence Entry Engine to a standard candlestick chart and pick Dark, Light or Mobile theme.
  2. Start with Pivot Lookback 5 and Confirmation Bars 1, and Trend Filter Off to see raw divergence frequency.
  3. Read the RSI pane and the neon price line as the same event, shown twice.
  4. Remember the neon line sits at the historical pivots — the entry label marks the candle the trade actually opened.
  5. Then test EMA Trend, Supertrend and HTF Trend to see which filter suits your market.
  6. Set ATR 14 and stop distance 2.0 to begin, and choose a TP3 target you would realistically hold for.
  7. Treat TP1 and TP2 as guide levels — the engine does not take partials or move to break-even.
  8. Read the dashboard as this script's own bar-touch record on loaded history, not as verified performance.
Written guide

10 pages, included

All 10 pages are open to every member.

It is free and open-source.
Read it, then run it.