INVITE-ONLY SCRIPT

Smart Divergence Engine Overlay [ChartNation]

80
What this does

This overlay projects the Smart Divergence Engine’s confirmed RSI divergences directly on the price chart. It draws compact lines between swing points and optional BUY/SELL labels anchored to the exact pivot candles, so the signals stick to the candles when you zoom or pan.

It uses the same internal engine as the panel version (smoothed RSI + stdev bands + pivot logic) but renders the result where most traders act—on price.

How it works

  • RSI engine. RSI is lightly smoothed, then a 34-period SMA with stdev bands frames regime/volatility context.
  • Pivot confirmation. Swings are defined by Pivot Left/Right. On the bar where a pivot confirms (after Pivot Right bars), the script compares price vs RSI at that pivot bar (rsi[pivotR]).
  • Bullish divergence: price lower low, RSI higher low.
  • Bearish divergence: price higher high, RSI lower high.
  • Overlay rendering. Lines are created between the two most recent confirmed pivots using bar indices, so drawings remain perfectly anchored to the candles.



Why this is useful


You get structure-true divergences (only after a swing is confirmed), drawn on price for immediate confluence with S/R, patterns, and candle context—no guesswork mapping from an oscillator pane.

Inputs (key)
  • Price Source, RSI Length (14)
  • Band Length (34), Band Multiplier (1.618)
  • Overbought / Oversold (68/32) – for internal offsets
  • Pivot Left / Right (10/10) – swing definition and confirmation delay
  • Show lines / Show labels, Line width, Bull/Bear colors


Visuals

Lines connecting the two pivots that form the divergence.
Optional BUY/SELL labels placed at the confirming pivot candle.


Alerts

  • Use these for automation or notifications:
  • Bullish Divergence (Overlay)
  • Bearish Divergence (Overlay)


How to use (practical)

  • Treat each printed divergence as context, then align with price action: break/retest, key levels, higher-timeframe bias.
  • In strong trends, counter-trend divergences are weaker—wait for structure shifts (e.g., HH/HL after a bull div, LH/LL after a bear div).


Notes & limitations

Signals appear after Pivot Right bars—this ties them to confirmed structure and prevents historical updating.
This is a price overlay only. If you want band/RSI context, pair it with the panel.

คำจำกัดสิทธิ์ความรับผิดชอบ

The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.