PROTECTED SOURCE SCRIPT
RSI DD – RSI Divergence Detector

RSI DD – RSI Divergence Detector (closed-source):
What it does:
Detects and plots regular and hidden RSI–price divergences using confirmed pivots on both series. Lines are drawn between the two most recent qualifying pivots; optional marks highlight OB/OS peaks at confirmation.
Detection method:
1. Compute RSI on a user-selected source and length. Optional EMA/SMA smoothing controls lag.
2. Build price and RSI pivot points with left/right lookbacks; a pivot confirms on the bar where right completes.
3. Pair the latest two pivots of the same type within a user-defined bar-distance window:
• Regular Bullish: price makes a lower low while RSI makes a higher low.
• Hidden Bullish: price makes a higher low while RSI makes a lower low.
• Regular Bearish: price makes a higher high while RSI makes a lower high.
• Hidden Bearish: price makes a lower high while RSI makes a higher high.
4. When a valid pair is found, draw a line on the RSI pane from the first RSI pivot to the second; color encodes divergence type.
5. Optional ticks mark RSI extremes when the confirming pivot is beyond OB/OS thresholds.
Inputs (key settings):
• RSI Period / Source: oscillator base.
• Pivot Lookback Left/Right: structure sensitivity; larger = fewer but stronger pivots.
• Min/Max Pairing Range: bars allowed between the two pivots; filters stale or too-tight pairs.
• Plot Toggles: enable/disable each divergence class.
• Signal Pair (visual): optional fast/slow MA pair and smoothing plotted as context; not used in detection.
• Levels: OB/OS and midline for visual regime.
Plots:
• RSI line.
• Optional RSI signal line.
• Midline (50), OB, OS levels.
• Colored divergence lines on RSI:
o Regular Bullish (aqua), Hidden Bullish (lime), Regular Bearish (yellow), Hidden Bearish (red).
• Optional OB/OS ticks at confirming pivots.
How to use:
• Works on any symbol and timeframe; higher timeframes reduce noise.
• Treat divergences as context. Combine with structure, trend, volume, and risk rules.
• Tighten stops or scale when divergence aligns with S/R and higher-TF bias.
• Increase right lookback and raise Min Range to reduce whipsaws; lower them to catch earlier turns.
Practical guidance:
• Swing trading: RSI 14, left=3/right=5, min=8/max=80, OB/OS 70/30.
• Intraday: RSI 14, left=2/right=3, min=4/max=40; consider slightly higher smoothing.
• If you see too many short lines, raise Min Range or increase right.
• If valid turns are missed, lower right or Min Range.
Limitations:
• Divergences can persist in strong trends.
• Pivot detection waits for confirmation, so signals are not predictive on the unconfirmed bar.
• OB/OS thresholds are conventional and not optimized to any asset.
Alerts (if you add alertcondition)
• Regular/Hidden Bullish/ Bearish detected on confirmation bar.
• Optional alert when RSI crosses back through midline after a divergence.
Version notes:
v2: pivot-pair range filter, optional OB/OS peak markers, object count management to prevent clutter, cosmetic controls, and visual signal pair.
Pine Script®
What it does:
Detects and plots regular and hidden RSI–price divergences using confirmed pivots on both series. Lines are drawn between the two most recent qualifying pivots; optional marks highlight OB/OS peaks at confirmation.
Detection method:
1. Compute RSI on a user-selected source and length. Optional EMA/SMA smoothing controls lag.
2. Build price and RSI pivot points with left/right lookbacks; a pivot confirms on the bar where right completes.
3. Pair the latest two pivots of the same type within a user-defined bar-distance window:
• Regular Bullish: price makes a lower low while RSI makes a higher low.
• Hidden Bullish: price makes a higher low while RSI makes a lower low.
• Regular Bearish: price makes a higher high while RSI makes a lower high.
• Hidden Bearish: price makes a lower high while RSI makes a higher high.
4. When a valid pair is found, draw a line on the RSI pane from the first RSI pivot to the second; color encodes divergence type.
5. Optional ticks mark RSI extremes when the confirming pivot is beyond OB/OS thresholds.
Inputs (key settings):
• RSI Period / Source: oscillator base.
• Pivot Lookback Left/Right: structure sensitivity; larger = fewer but stronger pivots.
• Min/Max Pairing Range: bars allowed between the two pivots; filters stale or too-tight pairs.
• Plot Toggles: enable/disable each divergence class.
• Signal Pair (visual): optional fast/slow MA pair and smoothing plotted as context; not used in detection.
• Levels: OB/OS and midline for visual regime.
Plots:
• RSI line.
• Optional RSI signal line.
• Midline (50), OB, OS levels.
• Colored divergence lines on RSI:
o Regular Bullish (aqua), Hidden Bullish (lime), Regular Bearish (yellow), Hidden Bearish (red).
• Optional OB/OS ticks at confirming pivots.
How to use:
• Works on any symbol and timeframe; higher timeframes reduce noise.
• Treat divergences as context. Combine with structure, trend, volume, and risk rules.
• Tighten stops or scale when divergence aligns with S/R and higher-TF bias.
• Increase right lookback and raise Min Range to reduce whipsaws; lower them to catch earlier turns.
Practical guidance:
• Swing trading: RSI 14, left=3/right=5, min=8/max=80, OB/OS 70/30.
• Intraday: RSI 14, left=2/right=3, min=4/max=40; consider slightly higher smoothing.
• If you see too many short lines, raise Min Range or increase right.
• If valid turns are missed, lower right or Min Range.
Limitations:
• Divergences can persist in strong trends.
• Pivot detection waits for confirmation, so signals are not predictive on the unconfirmed bar.
• OB/OS thresholds are conventional and not optimized to any asset.
Alerts (if you add alertcondition)
• Regular/Hidden Bullish/ Bearish detected on confirmation bar.
• Optional alert when RSI crosses back through midline after a divergence.
Version notes:
v2: pivot-pair range filter, optional OB/OS peak markers, object count management to prevent clutter, cosmetic controls, and visual signal pair.
Copyright © 2025 imaclone (Zen Silva). All rights reserved.
License: Private. No copying, sharing, or derivative works. Use limited to this TradingView script. Contact owner for access.
Скрипт с защищённым кодом
Этот скрипт опубликован с закрытым исходным кодом. Однако вы можете использовать его свободно и без каких-либо ограничений — читайте подробнее здесь.
Отказ от ответственности
Все виды контента, которые вы можете увидеть на TradingView, не являются финансовыми, инвестиционными, торговыми или любыми другими рекомендациями. Мы не предоставляем советы по покупке и продаже активов. Подробнее — в Условиях использования TradingView.
Скрипт с защищённым кодом
Этот скрипт опубликован с закрытым исходным кодом. Однако вы можете использовать его свободно и без каких-либо ограничений — читайте подробнее здесь.
Отказ от ответственности
Все виды контента, которые вы можете увидеть на TradingView, не являются финансовыми, инвестиционными, торговыми или любыми другими рекомендациями. Мы не предоставляем советы по покупке и продаже активов. Подробнее — в Условиях использования TradingView.