RSI Divergence Strength + ATR Extension

CONFIRMED RSI DIVERGENCE + ATR EXTENSION
OVERVIEW
This indicator finds regular RSI divergences, measures their size in percentage terms, and waits for price to confirm them before printing a signal. It also shows how far price has stretched from its 50-period moving average in ATR units, so each divergence can be read in the context of how extended the move is.
The goal is a clean chart. The price chart shows only a small triangle for each confirmed signal, while the divergence lines, percentages and ATR reading stay in the RSI pane.
WHAT MAKES IT DIFFERENT
Many divergence tools mark every disagreement between price and RSI. This script combines four ideas into one workflow:
1. Quality rules remove small divergences and divergences that form while RSI is not stretched.
2. Price confirmation keeps a setup on hold until price closes through a trigger level.
3. Percentage measurement shows how much price and RSI each changed between the two pivots.
4. ATR Extension shows whether price is close to its moving average or far away from it.
HOW A SIGNAL IS BUILT
Step 1: Find the pivots
RSI pivot highs and lows are detected using the Pivot left bars and Pivot right bars settings. Because price often peaks or bottoms slightly before or after RSI, the script looks up to 2 bars either side of the RSI pivot for the matching price high or low. This search never looks beyond the pivot's confirmation bar.
Step 2: Compare with earlier pivots
Each new pivot is compared with up to 5 earlier pivots of the same kind. The two pivots must be between 5 and 60 bars apart. The nearest valid pivot is used.
Step 3: Check the divergence
Bullish divergence: price makes a lower low while RSI makes a higher low.
Bearish divergence: price makes a higher high while RSI makes a lower high.
Step 4: Apply the quality rules
The Signal quality setting controls these rules.
Strict (default)
- Bullish: the lower RSI pivot must be at or below 35
- Bearish: the higher RSI pivot must be at or above 65
- RSI must differ by at least 5 points between pivots
- Price must differ by at least 0.5 ATR between pivots
- At least 15 bars between signals on the same side
Normal
- Bullish: the lower RSI pivot must be at or below 40
- Bearish: the higher RSI pivot must be at or above 60
- RSI must differ by at least 3 points between pivots
- Price must differ by at least 0.25 ATR between pivots
- At least 10 bars between signals on the same side
RSI must also stay on the correct side of the straight line joining the two pivots. If RSI cuts through that line, the divergence is rejected.
Step 5: Wait for price confirmation
When Wait for price confirmation is enabled, a valid divergence becomes a pending setup.
Bullish setup: the trigger is the highest high of the bars from the pivot through the detection bar. A close above that level confirms the signal.
Bearish setup: the trigger is the lowest low of the bars from the pivot through the detection bar. A close below that level confirms the signal.
A pending setup is cancelled if price closes beyond the second pivot, or if it does not confirm within 10 bars. A newer setup on the same side replaces an older pending setup.
If confirmation is disabled, the signal prints as soon as the divergence is detected.
HOW TO READ THE PERCENTAGES
Each divergence label in the RSI pane looks like this:
P +3.00% | RSI -16.67% | ATR +4.00x
P (Price %) = (Price 2 - Price 1) / Price 1 x 100
RSI % = (RSI 2 - RSI 1) / RSI 1 x 100
Gap % = absolute value of (Price % - RSI %)
ATR = ATR X from the moving average on the signal bar
Example: price rises from 100 to 103 while RSI falls from 72 to 60.
Price % = +3.00%
RSI % = -16.67%
RSI points = -12.00
Gap % = 19.67%
Hover over any label to see both price values, both RSI values, the RSI point change, Gap % and ATR X.
Gap % is usually driven more by RSI than by price because RSI tends to change by a larger percentage. It is best used to compare divergences on the same symbol and timeframe.
COLOR STRENGTH
Signals are shaded by Gap %. Larger gaps are brighter and smaller gaps are darker.
- At or below 15% Gap: darkest color
- Between 15% and 45% Gap: gradual blend
- At or above 45% Gap: brightest color
Red is used for bearish signals and green for bullish signals. The RSI line, label and price chart triangle all use the same shade. Both levels and all four colors can be changed in the settings.
Color shows the size of the divergence. It does not show the probability that a signal will work.
ATR X FROM THE 50 MA
ATR X = (Close - Moving Average) / ATR(14)
Example: close is 120, the 50 SMA is 110 and ATR(14) is 2.50.
ATR X = (120 - 110) / 2.50 = +4.00x
Positive values mean price is above the moving average. Negative values mean price is below it.
The current reading appears in a badge at the top right of the RSI pane. The badge is gray in normal conditions, uses the bearish color when price is at or beyond the positive alert level, and uses the bullish color when price is at or beyond the negative alert level. Historical values are available in the status line and Data Window.
The moving average length and type (SMA or EMA) can be changed. ATR X uses the chart's timeframe, so normal readings vary by symbol and timeframe.
ALERTS:
All alerts use a single TradingView alert condition:
1. Add the indicator to your chart and choose your settings.
2. Open Create Alert.
3. Under Condition, select this indicator.
4. Select Any alert() function call.
5. Choose your notification method and create the alert.
Options in the Alerts section:
- Enable alerts: turns all alerts on or off
- Bullish signals: alerts on confirmed bullish signals
- Bearish signals: alerts on confirmed bearish signals
- Early alert when a setup forms: alerts when a divergence appears, before confirmation, and includes the trigger price
- Alert when ATR X from MA is reached: alerts once when price closes beyond the chosen level, above or below the moving average
- ATR X alert level: default is 4.0
- Message format: Text or JSON
Text example:
AMD 15: Bullish RSI divergence confirmed at 512.30 | P -2.10% | RSI +12.40% | ATR X from 50 SMA: -1.85x
Divergence JSON fields:
ticker, tf, type, stage, close, trigger, price_pct, rsi_pct, rsi_pts, gap_pct, atr_x, ma
ATR X JSON fields:
ticker, tf, type, side, close, atr_x, level, ma
TradingView alerts keep the settings that existed when they were created. After changing a setting or updating the script, delete the alert and create it again.
On eligible TradingView plans, the same condition can be used in a watchlist alert to monitor every symbol in a list.
SETTINGS
Main
- RSI length: default 14
- Signal quality: Strict or Normal
- Wait for price confirmation: on by default
- Pivot left bars: default 5
- Pivot right bars: default 3
- Divergences to show: default 4
- Draw lines on price chart: off by default
- RSI color
Color by Gap %
- Darkest at Gap %: default 15
- Brightest at Gap %: default 45
- Bright and dark colors for bullish and bearish signals
ATR X from MA
- MA length: default 50
- MA type: default SMA
- Show ATR X in RSI pane: on by default
REPAINTING AND SIGNAL TIMING
Signals and alerts are evaluated at bar close. A pivot needs the selected number of right bars before it can be used, so divergence detection is delayed by design.
The divergence line and label are drawn back on the original pivots, but they do not appear until the signal has fired. The triangle on the price chart marks the bar where the signal became available. Use the triangle, not the earlier pivot, when reviewing historical signals.
The ATR X badge updates during the live bar because it uses the current price. The ATR X alert is evaluated only at bar close.
HOW TO USE IT
- Look for bearish signals when price is strongly extended above its moving average, and bullish signals when it is strongly extended below it.
- Compare the shade and Gap % with earlier signals on the same symbol.
- Check nearby support, resistance, trend, volume and market conditions.
- Use Strict for fewer signals and Normal for more signals.
- Disable price confirmation only if earlier signals matter more to you than extra confirmation.
- Define your entry, invalidation level and position size before acting on a signal.
LIMITATIONS
- Divergence can persist while a strong trend continues.
- Waiting for confirmation can lead to a later entry and may miss fast reversals.
- Early alerts are not confirmed signals, and some setups will be cancelled.
- The default thresholds may need adjustment for different symbols and timeframes.
- This script does not include backtest results, trade management or trading costs.
DISCLAIMER
This indicator is provided for educational and informational purposes only. It is not financial advice and does not guarantee any result. Past behavior does not indicate future performance. Always do your own research and manage your risk.
If you find this useful, a boost is appreciated. Suggestions and feedback welcome in the comments.
Open-source — feel free to study, fork, and adapt.
OVERVIEW
This indicator finds regular RSI divergences, measures their size in percentage terms, and waits for price to confirm them before printing a signal. It also shows how far price has stretched from its 50-period moving average in ATR units, so each divergence can be read in the context of how extended the move is.
The goal is a clean chart. The price chart shows only a small triangle for each confirmed signal, while the divergence lines, percentages and ATR reading stay in the RSI pane.
WHAT MAKES IT DIFFERENT
Many divergence tools mark every disagreement between price and RSI. This script combines four ideas into one workflow:
1. Quality rules remove small divergences and divergences that form while RSI is not stretched.
2. Price confirmation keeps a setup on hold until price closes through a trigger level.
3. Percentage measurement shows how much price and RSI each changed between the two pivots.
4. ATR Extension shows whether price is close to its moving average or far away from it.
HOW A SIGNAL IS BUILT
Step 1: Find the pivots
RSI pivot highs and lows are detected using the Pivot left bars and Pivot right bars settings. Because price often peaks or bottoms slightly before or after RSI, the script looks up to 2 bars either side of the RSI pivot for the matching price high or low. This search never looks beyond the pivot's confirmation bar.
Step 2: Compare with earlier pivots
Each new pivot is compared with up to 5 earlier pivots of the same kind. The two pivots must be between 5 and 60 bars apart. The nearest valid pivot is used.
Step 3: Check the divergence
Bullish divergence: price makes a lower low while RSI makes a higher low.
Bearish divergence: price makes a higher high while RSI makes a lower high.
Step 4: Apply the quality rules
The Signal quality setting controls these rules.
Strict (default)
- Bullish: the lower RSI pivot must be at or below 35
- Bearish: the higher RSI pivot must be at or above 65
- RSI must differ by at least 5 points between pivots
- Price must differ by at least 0.5 ATR between pivots
- At least 15 bars between signals on the same side
Normal
- Bullish: the lower RSI pivot must be at or below 40
- Bearish: the higher RSI pivot must be at or above 60
- RSI must differ by at least 3 points between pivots
- Price must differ by at least 0.25 ATR between pivots
- At least 10 bars between signals on the same side
RSI must also stay on the correct side of the straight line joining the two pivots. If RSI cuts through that line, the divergence is rejected.
Step 5: Wait for price confirmation
When Wait for price confirmation is enabled, a valid divergence becomes a pending setup.
Bullish setup: the trigger is the highest high of the bars from the pivot through the detection bar. A close above that level confirms the signal.
Bearish setup: the trigger is the lowest low of the bars from the pivot through the detection bar. A close below that level confirms the signal.
A pending setup is cancelled if price closes beyond the second pivot, or if it does not confirm within 10 bars. A newer setup on the same side replaces an older pending setup.
If confirmation is disabled, the signal prints as soon as the divergence is detected.
HOW TO READ THE PERCENTAGES
Each divergence label in the RSI pane looks like this:
P +3.00% | RSI -16.67% | ATR +4.00x
P (Price %) = (Price 2 - Price 1) / Price 1 x 100
RSI % = (RSI 2 - RSI 1) / RSI 1 x 100
Gap % = absolute value of (Price % - RSI %)
ATR = ATR X from the moving average on the signal bar
Example: price rises from 100 to 103 while RSI falls from 72 to 60.
Price % = +3.00%
RSI % = -16.67%
RSI points = -12.00
Gap % = 19.67%
Hover over any label to see both price values, both RSI values, the RSI point change, Gap % and ATR X.
Gap % is usually driven more by RSI than by price because RSI tends to change by a larger percentage. It is best used to compare divergences on the same symbol and timeframe.
COLOR STRENGTH
Signals are shaded by Gap %. Larger gaps are brighter and smaller gaps are darker.
- At or below 15% Gap: darkest color
- Between 15% and 45% Gap: gradual blend
- At or above 45% Gap: brightest color
Red is used for bearish signals and green for bullish signals. The RSI line, label and price chart triangle all use the same shade. Both levels and all four colors can be changed in the settings.
Color shows the size of the divergence. It does not show the probability that a signal will work.
ATR X FROM THE 50 MA
ATR X = (Close - Moving Average) / ATR(14)
Example: close is 120, the 50 SMA is 110 and ATR(14) is 2.50.
ATR X = (120 - 110) / 2.50 = +4.00x
Positive values mean price is above the moving average. Negative values mean price is below it.
The current reading appears in a badge at the top right of the RSI pane. The badge is gray in normal conditions, uses the bearish color when price is at or beyond the positive alert level, and uses the bullish color when price is at or beyond the negative alert level. Historical values are available in the status line and Data Window.
The moving average length and type (SMA or EMA) can be changed. ATR X uses the chart's timeframe, so normal readings vary by symbol and timeframe.
ALERTS:
All alerts use a single TradingView alert condition:
1. Add the indicator to your chart and choose your settings.
2. Open Create Alert.
3. Under Condition, select this indicator.
4. Select Any alert() function call.
5. Choose your notification method and create the alert.
Options in the Alerts section:
- Enable alerts: turns all alerts on or off
- Bullish signals: alerts on confirmed bullish signals
- Bearish signals: alerts on confirmed bearish signals
- Early alert when a setup forms: alerts when a divergence appears, before confirmation, and includes the trigger price
- Alert when ATR X from MA is reached: alerts once when price closes beyond the chosen level, above or below the moving average
- ATR X alert level: default is 4.0
- Message format: Text or JSON
Text example:
AMD 15: Bullish RSI divergence confirmed at 512.30 | P -2.10% | RSI +12.40% | ATR X from 50 SMA: -1.85x
Divergence JSON fields:
ticker, tf, type, stage, close, trigger, price_pct, rsi_pct, rsi_pts, gap_pct, atr_x, ma
ATR X JSON fields:
ticker, tf, type, side, close, atr_x, level, ma
TradingView alerts keep the settings that existed when they were created. After changing a setting or updating the script, delete the alert and create it again.
On eligible TradingView plans, the same condition can be used in a watchlist alert to monitor every symbol in a list.
SETTINGS
Main
- RSI length: default 14
- Signal quality: Strict or Normal
- Wait for price confirmation: on by default
- Pivot left bars: default 5
- Pivot right bars: default 3
- Divergences to show: default 4
- Draw lines on price chart: off by default
- RSI color
Color by Gap %
- Darkest at Gap %: default 15
- Brightest at Gap %: default 45
- Bright and dark colors for bullish and bearish signals
ATR X from MA
- MA length: default 50
- MA type: default SMA
- Show ATR X in RSI pane: on by default
REPAINTING AND SIGNAL TIMING
Signals and alerts are evaluated at bar close. A pivot needs the selected number of right bars before it can be used, so divergence detection is delayed by design.
The divergence line and label are drawn back on the original pivots, but they do not appear until the signal has fired. The triangle on the price chart marks the bar where the signal became available. Use the triangle, not the earlier pivot, when reviewing historical signals.
The ATR X badge updates during the live bar because it uses the current price. The ATR X alert is evaluated only at bar close.
HOW TO USE IT
- Look for bearish signals when price is strongly extended above its moving average, and bullish signals when it is strongly extended below it.
- Compare the shade and Gap % with earlier signals on the same symbol.
- Check nearby support, resistance, trend, volume and market conditions.
- Use Strict for fewer signals and Normal for more signals.
- Disable price confirmation only if earlier signals matter more to you than extra confirmation.
- Define your entry, invalidation level and position size before acting on a signal.
LIMITATIONS
- Divergence can persist while a strong trend continues.
- Waiting for confirmation can lead to a later entry and may miss fast reversals.
- Early alerts are not confirmed signals, and some setups will be cancelled.
- The default thresholds may need adjustment for different symbols and timeframes.
- This script does not include backtest results, trade management or trading costs.
DISCLAIMER
This indicator is provided for educational and informational purposes only. It is not financial advice and does not guarantee any result. Past behavior does not indicate future performance. Always do your own research and manage your risk.
If you find this useful, a boost is appreciated. Suggestions and feedback welcome in the comments.
Open-source — feel free to study, fork, and adapt.
免責事項
これらの情報および投稿は、TradingViewが提供または承認する金融、投資、取引、またはその他の種類の助言もしくは推奨であることを意図したものではなく、またこれらに該当するものでもありません。詳細は利用規約をご覧ください。
免責事項
これらの情報および投稿は、TradingViewが提供または承認する金融、投資、取引、またはその他の種類の助言もしくは推奨であることを意図したものではなく、またこれらに該当するものでもありません。詳細は利用規約をご覧ください。