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에서 제공하거나 보증하는 금융, 투자, 거래 또는 기타 유형의 조언이나 권고 사항을 의미하거나 구성하지 않습니다. 자세한 내용은 이용 약관을 참고하세요.