OPEN-SOURCE SCRIPT

Divergence – RSI & Volume with optional OBV/OI confirm (v6)

163
Divergence — RSI & Volume with optional OBV/OI confirmation

Overview
This indicator highlights bullish/bearish divergences between price and RSI and can optionally require a Volume divergence too. For further confluence, it can check OBV or Open Interest (OI) trend/structure as a confirmation filter. The goal is to surface potential exhaustion or continuation areas across multiple forms of momentum/participation—not to provide trade signals.

What it looks for:

*RSI divergences (regular & hidden):
*Regular bullish: Price makes a lower low while RSI makes a higher low.
*Regular bearish: Price makes a higher high while RSI makes a lower high.
*Hidden bullish: Price makes a higher low while RSI makes a lower low (trend-continuation).
*Hidden bearish: Price makes a lower high while RSI makes a higher high (trend-continuation).

Volume divergence (optional):
Price makes a new swing extreme without supportive volume, or volume makes a diverging swing relative to price.

Confirmation (optional):
  • OBV: requires OBV to agree with (or fail to confirm) price at the swing, per your filter setting.
  • OI: for markets with open interest data; checks whether OI supports or contradicts the move.


How it works (methodology)
Divergences are detected using confirmed swing points (pivot highs/lows). A swing is confirmed only after enough bars to the right have printed.

While a swing is forming, potential signals may appear and disappear; once the swing confirms, the plot is fixed.

Volume and OBV/OI checks are applied at the same swing points to avoid look-ahead bias.

Key inputs
  1. RSI: length & source.
  2. Swing settings: left/right bars (pivot strength), minimum spacing between swings.
  3. Divergence types: enable/disable regular and hidden (bullish/bearish) separately.
  4. Volume filter: toggle on/off; choose interpretation (e.g., lower participation on new price extreme).
  5. Confirmation source: None / OBV / OI and its strictness (must confirm vs must diverge).


Visuals: show/hide labels & lines, label side (left/right), colors, and max lookback markers.
Data availability: If OI is not available for the symbol/exchange, OI confirmation is automatically skipped.

What it draws
*Clear labels/markers at the confirmed swing bar, color-coded for bullish vs bearish and regular vs hidden.
*Optional connector lines between the last two relevant swing points for price and RSI.
*(If enabled) small badges indicating VOL, OBV, or OI confirmation status.


Notes & limitations

This is a charting tool. It does not generate trade recommendations or guarantees.

Divergence is context-dependent; many valid divergences fail in strong trends.

Signals depend on pivot confirmation; earlier bars may repaint until the swing is locked in.

OI is only present on instruments/exchanges that provide it; otherwise, OI checks do nothing.

Different chart sessions/aggregation (e.g., Heikin Ashi, RTH vs ETH) will produce different swing/RSI outcomes.

Best practices

Use divergences as confluence with structure (S/R, trends), higher-timeframe bias, and risk controls.

Prefer confirmed swings; be cautious with early prints.

Consider requiring Volume and OBV/OI filters in strong-trend environments to reduce noise.

Disclaimer
For educational purposes only. This is not financial advice or a solicitation to buy/sell any asset. Trading involves risk; do your own research and manage risk appropriately.
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.


gleefulJaguar47150
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.

Exención de responsabilidad

La información y las publicaciones que ofrecemos, no implican ni constituyen un asesoramiento financiero, ni de inversión, trading o cualquier otro tipo de consejo o recomendación emitida o respaldada por TradingView. Puede obtener información adicional en las Condiciones de uso.