OPEN-SOURCE SCRIPT
RSI Divergence Detector - HDAlgo

RSI Divergence Detector — Automatically Spot Reversal & Continuation Signals
This indicator automatically detects Regular and Hidden RSI Divergences and plots them directly on the RSI panel with visual lines and labels.
What It Detects
Regular Divergence (Reversal Signals):
Bullish Divergence — Price makes a lower low, but RSI makes a higher low. This signals weakening selling pressure and a potential reversal to the upside.
Bearish Divergence — Price makes a higher high, but RSI makes a lower high. This signals weakening buying pressure and a potential reversal to the downside.
Hidden Divergence (Trend Continuation Signals):
Hidden Bullish — Price makes a higher low, but RSI makes a lower low. Suggests the uptrend is likely to continue.
Hidden Bearish — Price makes a lower high, but RSI makes a higher high. Suggests the downtrend is likely to continue.
Visual Guide
🟢 Green label "Bull" + solid green line = Regular Bullish Divergence
🔴 Red label "Bear" + solid red line = Regular Bearish Divergence
🔺 Lime triangle + dashed line = Hidden Bullish Divergence
🔻 Orange triangle + dashed line = Hidden Bearish Divergence
Settings
RSI Length — Default 14. Standard RSI period.
Pivot Lookback Left / Right — Controls how significant a pivot must be. Higher = fewer but stronger signals.
Min / Max Bars Between Pivots — Filters out divergences that are too close or too far apart.
Show Bullish / Bearish / Hidden — Toggle each divergence type on or off.
How to Use
For reversals: Look for Regular Bullish Divergence near support zones or Regular Bearish Divergence near resistance zones.
For trend continuation: Enable Hidden Divergence to confirm that the current trend is still intact.
Best combined with: Stochastic crossover in oversold/overbought zones, volume confirmation, and key support/resistance levels from higher timeframes.
Alerts
Built-in alert conditions for all 4 divergence types — set them up via TradingView's alert menu so you never miss a signal.
Note: Divergence is not a standalone signal. Always confirm with price action, volume, and other confluence factors before entering a trade. This indicator has a natural delay of Pivot Lookback Right bars to confirm pivots.
This indicator automatically detects Regular and Hidden RSI Divergences and plots them directly on the RSI panel with visual lines and labels.
What It Detects
Regular Divergence (Reversal Signals):
Bullish Divergence — Price makes a lower low, but RSI makes a higher low. This signals weakening selling pressure and a potential reversal to the upside.
Bearish Divergence — Price makes a higher high, but RSI makes a lower high. This signals weakening buying pressure and a potential reversal to the downside.
Hidden Divergence (Trend Continuation Signals):
Hidden Bullish — Price makes a higher low, but RSI makes a lower low. Suggests the uptrend is likely to continue.
Hidden Bearish — Price makes a lower high, but RSI makes a higher high. Suggests the downtrend is likely to continue.
Visual Guide
🟢 Green label "Bull" + solid green line = Regular Bullish Divergence
🔴 Red label "Bear" + solid red line = Regular Bearish Divergence
🔺 Lime triangle + dashed line = Hidden Bullish Divergence
🔻 Orange triangle + dashed line = Hidden Bearish Divergence
Settings
RSI Length — Default 14. Standard RSI period.
Pivot Lookback Left / Right — Controls how significant a pivot must be. Higher = fewer but stronger signals.
Min / Max Bars Between Pivots — Filters out divergences that are too close or too far apart.
Show Bullish / Bearish / Hidden — Toggle each divergence type on or off.
How to Use
For reversals: Look for Regular Bullish Divergence near support zones or Regular Bearish Divergence near resistance zones.
For trend continuation: Enable Hidden Divergence to confirm that the current trend is still intact.
Best combined with: Stochastic crossover in oversold/overbought zones, volume confirmation, and key support/resistance levels from higher timeframes.
Alerts
Built-in alert conditions for all 4 divergence types — set them up via TradingView's alert menu so you never miss a signal.
Note: Divergence is not a standalone signal. Always confirm with price action, volume, and other confluence factors before entering a trade. This indicator has a natural delay of Pivot Lookback Right bars to confirm pivots.
Open-source script
In true TradingView spirit, the creator of this script has made it open-source, so that traders can review and verify its functionality. Kudos to the author! While you can use it for free, remember that republishing the code is subject to our House Rules.
Disclaimer
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.
Open-source script
In true TradingView spirit, the creator of this script has made it open-source, so that traders can review and verify its functionality. Kudos to the author! While you can use it for free, remember that republishing the code is subject to our House Rules.
Disclaimer
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.