OPEN-SOURCE SCRIPT

Smart RSI Divergence PRO | Auto Lines + Alerts

231
📌 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.

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.