OPEN-SOURCE SCRIPT

Open Interest RSI [BackQuant]

665
Open Interest RSI [BackQuant]
A multi-venue open interest oscillator that aggregates OI across major derivatives exchanges, converts it to coin or USD terms, and runs an RSI-style engine on that aggregated OI so you can track positioning pressure, crowding, and mean reversion in leverage flows, not just in price.

What this is
This tool is an RSI built on top of aggregated open interest instead of price. It pulls futures OI from several major exchanges, converts it into a unified unit (COIN or USD), sums it into a single synthetic OI candle, then applies RSI and smoothing to that combined series.

You can then render that Open Interest RSI in different visual modes:
  • Clean line or colored line for classic oscillator-style reads.
  • Column-style oscillator for impulse and compression views.
  • Flag mode that fills between OI RSI and its EMA for trend/mean reversion blends. See: snapshot
  • Heatmap mode that paints the panel based on OI RSI extremes, ideal for scanning. See: snapshot


On top of that it includes:
  • Aggregated OI source selection (Binance, Bybit, OKX, Bitget, Kraken, HTX, Deribit).
  • Choice of OI units (COIN or USD).
  • Reference lines and OB/OS zones.
  • Extreme highlighting for either trend or mean reversion.
  • A vertical OI RSI meter that acts as a quick strength gauge.


Aggregated open interest source
Under the hood, the indicator builds a synthetic open interest candle by:
  • Looping over a list of supported exchanges: Binance, Bybit, OKX, Bitget, Kraken, HTX, Deribit.
  • Looping over multiple contract suffixes (such as USDT.P, USD.P, USDC.P, USD.PM) to capture different contract types on each venue.
  • Requesting OI candles from each venue + contract combination for the same underlying symbol.
  • Converting each OI stream into a common unit: In COIN mode, everything is normalized into coin-denominated OI. In USD mode, coin OI is multiplied by price to approximate notional OI.
  • Summing up open, high, low and close of OI across venues into a single aggregated OI candle.


If no valid OI is available for the current symbol across all sources, the script throws a clear runtime error so you know you are on an unsupported market.

This gives you a single, exchange-agnostic open interest curve instead of being tied to one venue. That aggregated OI is then passed into the RSI logic.

How the OI RSI is calculated
The RSI side is straightforward, but it is applied to the aggregated OI close:
  • Compute a base RSI of aggregated OI using the Calculation Period.
  • Apply a simple moving average of length Smoothing Period (SMA) to reduce noise in the raw OI RSI.
  • Optionally apply an EMA on top of the smoothed OI RSI as a moving average signal line.


Key parameters:
  • Calculation Period – base RSI length for OI.
  • Smoothing Period (SMA) – extra smoothing on the RSI value.
  • EMA Period – EMA length on the smoothed OI RSI.


The result is:
  • oi_rsi – raw RSI of aggregated OI.
  • oi_rsi_s – SMA-smoothed OI RSI.
  • ma – EMA of the smoothed OI RSI.


Thresholds and extremes
You control three core thresholds:
  • Mid Point – central reference level, typically 50.
  • Extreme Upper Threshold – high-level OI RSI edge (for example 80).
  • Extreme Lower Threshold – low-level OI RSI edge (for example 20).


These thresholds are used for:
  • Reference lines or OB/OS zone fills.
  • Heatmap gradient bounds.
  • Background highlighting of extremes.


The Extreme Highlighting mode controls how extremes are interpreted:
  • None – do nothing special in extreme regions.
  • Mean-Rev – background turns red on high OI RSI and green on low OI RSI, framing extremes as contrarian zones.
  • Trend – background turns green on high OI RSI and red on low OI RSI, framing extremes as participation zones aligned with the prevailing move.


Reference lines and OB/OS zones
You can choose:
  • None – clean plotting without guides.
  • Basic Reference Lines – mid, upper and lower thresholds as simple gray horizontals.
  • OB/OS Levels – filled zones between:
    • Upper OB: from the upper threshold to 100, colored with the short/overbought color.
    • Lower OS: from 0 to the lower threshold, colored with the long/oversold color.


These guides help visually anchor the OI RSI within "normal" versus "extreme" regions.

Plotting modes
The Plotting Type input controls how OI RSI is drawn. All modes share the same underlying OI and RSI logic, but emphasise different aspects of the signal.

1) Line mode
This is the classic oscillator representation:
  • Plots the smoothed OI RSI as a simple line using RSI Line Color and RSI Line Width.
  • Optionally plots the EMA overlay on the same panel.
  • Works well when you want standard RSI-style signals on leverage flows: crosses of the midline, divergences versus price, and so on.


2) Colored Line mode
In this mode:
  • The OI RSI is plotted as a line, but its color is dynamic.
  • If the smoothed OI RSI is above the mid point, it uses the Long/OB Color.
  • If it is below the mid point, it uses the Short/OS Color.


This creates an instant visual regime switch between "bullish positioning pressure" and "bearish positioning pressure", while retaining the feel of a traditional RSI line.

3) Oscillator mode
Oscillator mode renders OI RSI as vertical columns around the mid level:
  • The smoothed OI RSI is plotted as columns using plot.style_columns.
  • The histogram base is fixed at 50, so bars extend above and below the mid line.
  • Bar color is dynamic, using long or short colors depending on which side of the mid point the value sits.


This representation makes impulse and compression in OI flows more obvious. It is especially useful when you want to focus on how quickly OI RSI is expanding or contracting around its neutral level. See: snapshot

4) Flag mode
Flag mode turns OI RSI and its EMA into a two-line band with a filled area between them:
  • The smoothed OI RSI and its EMA are both plotted.
  • A fill is drawn between them.
  • The fill color flips between the long color and the short color depending on whether OI RSI is above or below its EMA.
  • Black outlines are added to both lines to make the band clear against any background.


This creates a "flag" style region where:
  • Green fills show OI RSI leading its EMA, suggesting positive positioning momentum.
  • Red fills show OI RSI trailing below its EMA, suggesting negative positioning momentum.
  • Crossovers of the two lines can be read as shifts in OI momentum regime.


Flag mode is useful if you want a more structural view that combines both the level and slope behaviour of OI RSI. See: snapshot

5) Heatmap mode
Heatmap mode recasts OI RSI as a single-row gradient instead of a line:
  • A single row at level 1 is plotted using column style.
  • The color is pulled from a gradient between the lower and upper thresholds: Near the lower threshold it approaches the short/oversold color and near the upper threshold it approaches the long/overbought color.
  • The EMA overlay and reference lines are disabled in this mode to keep the panel clean.


This is a very compact way to track OI RSI state at a glance, especially when stacking it alongside other indicators. See: snapshot

OI RSI vertical meter
Beyond the main plot, the script can draw a small "thermometer" table showing the current OI RSI position from 0 to 100:
  • The meter is a two-column table with a configurable number of rows.
  • Row colors form an inverted gradient: red at the top (100) and green at the bottom (0).
  • The script clamps OI RSI between 0 and 100 and maps it to a row index.
  • An arrow marker "▶" is drawn next to the row corresponding to the current OI RSI value.
  • 0 and 100 labels are printed at the ends of the scale for orientation.


You control:
  • Show OI RSI Meter – turn the meter on or off.
  • OI RSI Blocks – number of vertical blocks (granularity).
  • OI RSI Meter Position – panel anchor (top/bottom, left/center/right).


The meter is particularly helpful if you keep the main plot in a small panel but still want an intuitive strength gauge.

How to read it as a market pressure gauge
Because this is an RSI built on aggregated open interest, its extremes and regimes speak to positioning pressure rather than price alone:
  • High OI RSI (near or above the upper threshold) indicates that open interest has been increasing aggressively relative to its recent history. This often coincides with crowded leverage and a buildup of directional pressure.
  • Low OI RSI (near or below the lower threshold) indicates aggressive de-leveraging or closing of positions, often associated with flushes, forced unwinds or post-liquidation clean-ups.
  • Values around the mid point indicate more balanced positioning flows.


You can combine this with price action:
  • Price up with rising OI RSI suggests fresh leverage joining the move, a more persistent trend.
  • Price up with falling OI RSI suggests shorts covering or longs taking profit, more fragile upside.
  • Price down with rising OI RSI suggests aggressive new shorts or levered selling.
  • Price down with falling OI RSI suggests de-leveraging and potential exhaustion of the move.


Trading applications

Trend confirmation on leverage flows
Use OI RSI to confirm or question a price trend:
  • In an uptrend, rising OI RSI with values above the mid point indicates supportive leverage flows.
  • In an uptrend, repeated failures to lift OI RSI above mid point or persistent weakness suggest less committed participation.
  • In a downtrend, strong OI RSI on the downside points to aggressive shorting.


Mean reversion in positioning
Use thresholds and the Mean-Rev highlight mode:
  • When OI RSI spends extended time above the upper threshold, the crowd is extended on one side. That can set up squeeze risk in the opposite direction.
  • When OI RSI has been pinned low, it suggests heavy de-leveraging. Once price stabilises, a re-risking phase is often not far away.
  • Background colours in Mean-Rev mode help visually identify these periods.


Regime mapping with plotting modes
Different plotting modes give different perspectives:
  • Heatmap mode for dashboard-style use where you just need to know "hot", "neutral" or "cold" on OI flows at a glance.
  • Oscillator mode for short term impulses and compression reads around the mid line. See: snapshot
  • Flag mode for blending level and trend of OI RSI into a single banded visual. See: snapshot


Settings overview

RSI group
  • Plotting Type – None, Line, Colored Line, Oscillator, Flag, Heatmap.
  • Calculation Period – base RSI length for OI.
  • Smoothing Period (SMA) – smoothing on RSI.


Moving Average group
  • Show EMA – toggle EMA overlay (not used in heatmap).
  • EMA Period – length of EMA on OI RSI.
  • EMA Color – colour of EMA line.


Thresholds group
  • Mid Point – central reference.
  • Extreme Upper Threshold and Extreme Lower Threshold – OB/OS thresholds.
  • Select Reference Lines – none, basic lines or OB/OS zone fills.
  • Extreme Highlighting – None, Mean-Rev, Trend.


Extra Plotting and UI
  • RSI Line Color and RSI Line Width.
  • Long/OB Color and Short/OS Color.
  • Show OI RSI Meter, OI RSI Blocks, OI RSI Meter Position.


Open Interest Source
  • OI Units – COIN or USD.
  • Exchange toggles: Binance, Bybit, OKX, Bitget, Kraken, HTX, Deribit.


Notes
This is a positioning and pressure tool, not a complete system. It:
  • Models aggregated futures open interest across multiple centralized exchanges.
  • Transforms that OI into an RSI-style oscillator for better comparability across regimes.
  • Offers several visual modes to match different workflows, from detailed analysis to compact dashboards.


Use it to understand how leverage and positioning are evolving behind the price, to gauge when the crowd is stretched, and to decide whether to lean with or against that pressure. Attach it to your existing signals, not in place of them.

Also, please check out NoveltyTrade for the OI Aggregation logic & pulling the data source!
Here is the original script:
Crypto OI Agregated

Aviso legal

As informações e publicações não se destinam a ser, e não constituem, conselhos ou recomendações financeiras, de investimento, comerciais ou de outro tipo fornecidos ou endossados pela TradingView. Leia mais nos Termos de Uso.