OPEN-SOURCE SCRIPT

RSI Cascade Divergences

181
RSI Cascade Divergences is a tool for detecting divergences between price and RSI with an extended cascade-based strength accumulation logic. A “cascade” represents a sequence of multiple divergences linked through RSI pivot points. The indicator records RSI pivots, checks whether a divergence is present, assigns a strength value to each structure, and displays only signals that meet your minimum strength thresholds.

How Divergence Logic Works
The indicator identifies local RSI extremes (pivots) based on Pivot Length and Pivot Confirm.
For every confirmed pivot it stores:
  • the RSI value at the pivot,
  • the corresponding value of the RSI Source price,
  • the pivot’s bar index.


How a Divergence Is Formed
A divergence is detected when two consecutive RSI pivots of the same type show opposite dynamics relative to the price source defined in RSI Source (default: close), not relative to chart highs/lows.
  • Bearish divergence: the price source value at the second pivot is higher, but RSI forms a lower high.
  • Bullish divergence: the price source value at the second pivot is lower, but RSI forms a higher low.

The indicator does not use price highs/lows — only the selected price source at the pivot points.

Cascade Strength Calculation
Each new pivot is compared only with the previous pivot of the same type.
A cascade grows in strength if:
  • divergence conditions are met,
  • the difference in RSI values exceeds Min. RSI Distance,
  • the previous structure already had some strength or the previous pivot was formed in the OB/OS zone.

If the divergence occurs as RSI exits OB/OS, strength is additionally increased by +1.

Behavior in Strong Trends
Divergences may appear repeatedly and even form cascades with high strength. However, if price does not react meaningfully, this indicates strong trend pressure.
In such cases, divergences stop functioning as reversal signals:
RSI attempts to counter-move, but the dominant trend continues.
The indicator accurately reflects this — cascades may form but fail to trigger any reversal, which itself suggests a powerful, persistent trend.

Filtering and Context Reset
To avoid retaining irrelevant pivots:
  • when RSI is above Overbought → low pivots are cleared;
  • when RSI is below Oversold → high pivots are cleared.

This prevents false cascades during extreme RSI conditions.

Input Parameters
RSI Source — price source used in RSI calculations (close, hl2, ohlc4, etc.).
RSI Length — RSI calculation period.
Overbought / Oversold — RSI threshold zones.
Pivot Length — number of bars to the left required for a pivot.
Pivot Confirm — bars to the right required to confirm the pivot.
Min. RSI Distance — minimum difference between two pivot RSI values for the divergence to be considered meaningful.
Min. Strength (Bull / Bear) — minimum accumulated strength for:
  • confirming the signal,
  • displaying the strength label,
  • triggering alerts.

Weaker signals below these thresholds appear as dashed guide structures.

Visual
Display settings for lines, markers, and colors.
These parameters do not affect the indicator logic.

Important
Divergences — including cascades — should not be used as a standalone trading signal.
Always combine them with broader market context, trend analysis, structure, volume, and risk management tools.

คำจำกัดสิทธิ์ความรับผิดชอบ

ข้อมูลและบทความไม่ได้มีวัตถุประสงค์เพื่อก่อให้เกิดกิจกรรมทางการเงิน, การลงทุน, การซื้อขาย, ข้อเสนอแนะ หรือคำแนะนำประเภทอื่น ๆ ที่ให้หรือรับรองโดย TradingView อ่านเพิ่มเติมใน ข้อกำหนดการใช้งาน