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.
Mã nguồn mở
Theo đúng tinh thần TradingView, tác giả của tập lệnh này đã công bố nó dưới dạng mã nguồn mở, để các nhà giao dịch có thể xem xét và xác minh chức năng. Chúc mừng tác giả! Mặc dù bạn có thể sử dụng miễn phí, hãy nhớ rằng việc công bố lại mã phải tuân theo Nội quy.
Thông báo miễn trừ trách nhiệm
Thông tin và các ấn phẩm này không nhằm mục đích, và không cấu thành, lời khuyên hoặc khuyến nghị về tài chính, đầu tư, giao dịch hay các loại khác do TradingView cung cấp hoặc xác nhận. Đọc thêm tại Điều khoản Sử dụng.
Mã nguồn mở
Theo đúng tinh thần TradingView, tác giả của tập lệnh này đã công bố nó dưới dạng mã nguồn mở, để các nhà giao dịch có thể xem xét và xác minh chức năng. Chúc mừng tác giả! Mặc dù bạn có thể sử dụng miễn phí, hãy nhớ rằng việc công bố lại mã phải tuân theo Nội quy.
Thông báo miễn trừ trách nhiệm
Thông tin và các ấn phẩm này không nhằm mục đích, và không cấu thành, lời khuyên hoặc khuyến nghị về tài chính, đầu tư, giao dịch hay các loại khác do TradingView cung cấp hoặc xác nhận. Đọc thêm tại Điều khoản Sử dụng.