OPEN-SOURCE SCRIPT
Smart RSI Divergence PRO | Auto Lines + Alerts

📌 Purpose
This indicator automatically detects Regular and Hidden RSI Divergences between price action and the RSI oscillator.
It plots divergence lines directly on the chart, labels signals, and includes alerts for automated monitoring.
🧠 How It Works
1. RSI Calculation
RSI is calculated using the selected Source (default: Close) and RSI Length (default: 14).
2. Divergence Detection via Fractals
Swing points on both price and RSI are detected using fractal logic (5-bar patterns).
Regular Divergence:
Bearish: Price forms a higher high, RSI forms a lower high.
Bullish: Price forms a lower low, RSI forms a higher low.
Hidden Divergence:
Bearish: Price forms a lower high, RSI forms a higher high.
Bullish: Price forms a higher low, RSI forms a lower low.
3. Auto Drawing Lines
Lines are drawn automatically between divergence points:
Red = Regular Bearish
Green = Regular Bullish
Orange = Hidden Bearish
Blue = Hidden Bullish
Line width and transparency are adjustable.
4. Labels and Alerts
Labels mark divergence points with up/down arrows.
Alerts trigger for each divergence type.
📈 How to Use
Use Regular Divergences to anticipate trend reversals.
Use Hidden Divergences to confirm trend continuation.
Combine with support/resistance, trendlines, or volume for higher probability setups.
Recommended Timeframes: Works on all timeframes; more reliable on 1h, 4h, and Daily.
Markets: Forex, Crypto, Stocks.
⚙️ Inputs
Source (Close, HL2, etc.)
RSI Length
Toggle Regular / Hidden Divergence visibility
Toggle Lines / Labels
Line Width & Line Transparency
⚠️ Disclaimer
This script is for educational purposes only. It does not constitute financial advice.
Always test thoroughly before using in live trading.
This indicator automatically detects Regular and Hidden RSI Divergences between price action and the RSI oscillator.
It plots divergence lines directly on the chart, labels signals, and includes alerts for automated monitoring.
🧠 How It Works
1. RSI Calculation
RSI is calculated using the selected Source (default: Close) and RSI Length (default: 14).
2. Divergence Detection via Fractals
Swing points on both price and RSI are detected using fractal logic (5-bar patterns).
Regular Divergence:
Bearish: Price forms a higher high, RSI forms a lower high.
Bullish: Price forms a lower low, RSI forms a higher low.
Hidden Divergence:
Bearish: Price forms a lower high, RSI forms a higher high.
Bullish: Price forms a higher low, RSI forms a lower low.
3. Auto Drawing Lines
Lines are drawn automatically between divergence points:
Red = Regular Bearish
Green = Regular Bullish
Orange = Hidden Bearish
Blue = Hidden Bullish
Line width and transparency are adjustable.
4. Labels and Alerts
Labels mark divergence points with up/down arrows.
Alerts trigger for each divergence type.
📈 How to Use
Use Regular Divergences to anticipate trend reversals.
Use Hidden Divergences to confirm trend continuation.
Combine with support/resistance, trendlines, or volume for higher probability setups.
Recommended Timeframes: Works on all timeframes; more reliable on 1h, 4h, and Daily.
Markets: Forex, Crypto, Stocks.
⚙️ Inputs
Source (Close, HL2, etc.)
RSI Length
Toggle Regular / Hidden Divergence visibility
Toggle Lines / Labels
Line Width & Line Transparency
⚠️ Disclaimer
This script is for educational purposes only. It does not constitute financial advice.
Always test thoroughly before using in live trading.
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.