Smart Divergence Engine [ChartNation]

Smart Divergence Engine is an RSI-based analysis panel that helps you spot momentum exhaustion and structure-backed reversals. It blends four concepts into one workflow:
- a smoothed RSI “price line,”
- volatility bands around that RSI,
- a “Shark Fin” re-entry filter that highlights stretched moves snapping back inside the bands, and
- pivot-confirmed RSI divergences (bullish/bearish) rendered cleanly on the panel with optional glow.
This script is designed to be a clear decision aid, not a mashup for its own sake—the components work together to qualify divergences with volatility context and proper swing confirmation.
How it works?
- RSI engine. The script computes RSI on your chosen source, then applies a light RMA smoothing to form the “price line.”
- Volatility bands. A 34-period SMA of the RSI creates a basis; standard deviation bands are projected using a configurable multiplier (default 1.618). The dotted 50 line anchors bias.
- Shark Fin (exhaustion cue). When RSI stretches beyond the outer band by a small buffer and then re-enters the band with slope confirmation and a minimum stdev (volatility) condition, the script fills the gap between RSI and the violated band (20% style by default). A cooldown avoids back-to-back signals.
- Confirmed divergences. Swing points are detected using Pivot Left/Right. When a new pivot confirms (i.e., after Pivot Right bars), the script compares price vs RSI at the pivot bar (rsi[pivotR]).
- Bullish divergence: price makes a lower low while RSI makes a higher low.
- Bearish divergence: price makes a higher high while RSI makes a lower high.
- Confirmed events are drawn as lines between the last two pivots with compact labels (“Bull” / “Bear”). Once printed, they do not update historically.
Why this is useful
Divergences alone can be noisy. By waiting for swing confirmation and adding a volatility-aware re-entry filter, the panel focuses attention on exhaustion areas that align with structure—reducing false positives during choppy conditions.
The gradient “beauty mode” improves readability of RSI regimes around the 50 midline without cluttering the pane.
Inputs (key settings)
- RSI Length (default 14) – momentum window.
- Volatility Band Length (34) and Band Multiplier (1.618) – widen/narrow band sensitivity.
- Overbought / Oversold (68/32) – horizontal guides and internal offsets for labels.
- Pivot Left / Pivot Right (default 10/10) – swing definition; divergence is evaluated at the pivot bar (rsi[pivotR]).
Shark Fin controls:
- Fin depth buffer (RSI pts) – how far beyond the band counts as “stretched.”
- Min band stdev – volatility threshold to qualify fins.
- Min bars between fins – cooldown.
- Style / Beauty Mode: optional gradient fill above/below 50, divergence line glow and widths, top/bottom colors, and opacity.
Visuals
- RSI line (thin, smoothed), upper/lower bands, 50 midline (dotted).
- Shark Fin shows only as a soft fill while forming; confirmations are alertable.
- Divergences draw compact lines + tiny dot + “Bull/Bear” labels on the panel. Glow and widths are user-tunable.
Alerts
Configure alerts on any chart/timeframe using these built-in conditions:
- “RSI Shark Fin — Bullish” – RSI re-entered from below the lower band (with slope + stdev + cooldown).
- “RSI Shark Fin — Bearish” – RSI re-entered from above the upper band (with slope + stdev + cooldown).
- “Bullish Divergence (Panel)” – pivot-confirmed bullish divergence.
- “Bearish Divergence (Panel)” – pivot-confirmed bearish divergence.
- How to use (practical playbook)
- Confluence first. Divergences are stronger when Shark Fin confirms exhaustion and RSI is transitioning around the 50 midline.
- Trend context. In strong trends, counter-trend divergences can fail; consider waiting for RSI to re-enter the band or reclaim/loss the 50 line.
- Risk management. Treat signals as context, not entries on their own—pair with price action (structure, S/R, candles) and a predefined stop/size plan.
Notes & limitations
Divergences and labels only appear after a swing completes (after Pivot Right bars). This keeps signals tied to confirmed structure.
This panel operates in oscillator space (overlay=false). If you prefer price-chart markers/lines, use the companion overlay version built on the same logic.
Script sob convite
Somente usuários aprovados pelo autor podem acessar este script. Você precisará solicitar e obter permissão para usá-lo. Normalmente, essa permissão é concedida após o pagamento. Para obter mais detalhes, siga as instruções do autor abaixo ou entre em contato diretamente com chartnation.
O TradingView NÃO recomenda pagar ou usar um script ao não ser que você confie totalmente no seu autor e compreende como isso funciona. Você pode também encontrar alternativas gratuitas e de código aberto em nossa comunidade de scripts.
Instruções do autor
Aviso legal
Script sob convite
Somente usuários aprovados pelo autor podem acessar este script. Você precisará solicitar e obter permissão para usá-lo. Normalmente, essa permissão é concedida após o pagamento. Para obter mais detalhes, siga as instruções do autor abaixo ou entre em contato diretamente com chartnation.
O TradingView NÃO recomenda pagar ou usar um script ao não ser que você confie totalmente no seu autor e compreende como isso funciona. Você pode também encontrar alternativas gratuitas e de código aberto em nossa comunidade de scripts.