PROTECTED SOURCE SCRIPT
Open Interest Matrix [Robinhodl21]

Turns raw open interest data into a regime detection system with statistical normalization, whale positioning flags, squeeze/divergence signals, and a multi-timeframe confirmation dashboard. Instead of guessing direction from candles, this reads where contracts are actually stacking — and flags when positioning becomes statistically extreme or when the single largest inflow in 100 bars hits. Works on crypto, futures, and any instrument where TradingView provides OI data.
Why open interest matters
Price tells you what happened. Open interest tells you what's being built. When price rises and OI rises with it, new money is entering — that's a genuine build-up. When price rises but OI falls, existing shorts are covering — no new conviction. The difference between these two regimes is the difference between a continuation and a trap. This indicator classifies those regimes automatically and layers statistical analysis on top.
Four analysis models
Whale detection
On every bar, the indicator computes the change in OI and compares it to the highest OI inflow over the lookback period (default 100 bars). When the current inflow equals the highest inflow and is positive, a whale event triggers. Direction is determined by the candle:
When bar coloring is enabled (default), whale bars render at full opacity to stand out from the regime-colored bars around them. This makes whale events immediately visible on any chart.
Multi-timeframe OI matrix
Three configurable timeframes (default: 1H, 4H, Daily) each pull OI data independently and compute the bar-over-bar delta. The dashboard shows each delta as a green (expanding) or red (contracting) value. This answers a critical question: is OI building on all timeframes, or just on the one you're watching?
Example: if 1H OI delta is positive but 4H and Daily are negative, the current OI build-up may be intraday noise, not a real positioning trend. When all three align green, the positioning signal is much stronger.
Squeeze and divergence signals
Both are off by default — enable them in Settings > Visuals.
Dashboard terminal
A table (default: top-right) showing:
Each dashboard section can be toggled on/off independently.
Data connection
Three modes for connecting to OI data:
Key inputs and defaults
Plot styles
Alerts
Two alert conditions available:
Limitations and shortcomings
Works on any timeframe where OI data is available. Best on 1H, 4H, and Daily. Pine Script v5. Open source. MPL 2.0 | Robinhodl21
Why open interest matters
Price tells you what happened. Open interest tells you what's being built. When price rises and OI rises with it, new money is entering — that's a genuine build-up. When price rises but OI falls, existing shorts are covering — no new conviction. The difference between these two regimes is the difference between a continuation and a trap. This indicator classifies those regimes automatically and layers statistical analysis on top.
Four analysis models
- Standard (Price vs OI) — The classic four-quadrant model. Compares the direction of price change against the direction of OI change on each bar:
Price up + OI up = LONG BUILD-UP (green) — new longs entering, bullish conviction
Price up + OI down = SHORT COVERING (teal) — shorts exiting, rally may lack follow-through
Price down + OI up = SHORT BUILD-UP (red) — new shorts entering, bearish conviction
Price down + OI down = LONG UNWINDING (light red) — longs exiting, decline may be exhaustion
Four regimes from two data points. Each bar is color-coded to its regime. The dashboard shows the current regime label in real time. - Statistical Z-Score (Sigma) — Default mode. Computes a 100-bar simple moving average and standard deviation of the OI series, then normalizes: . The result shows how many standard deviations current OI sits from its mean. Color gradient maps the Z-score: blue (#2196F3) at -2σ through gray at 0 to red (#FF5252) at +2σ. Values between -1σ and +1σ render as gray (normal range). Regime labels:
Pine Script® z = (oi - sma(oi, 100)) / stdev(oi, 100)
Z > +2.0σ → CROWDED (RISK) — statistically extreme positioning. Crowded trades are fragile; when the crowd is all on one side, the unwind can be violent.
Z < -1.5σ → APATHY — historically low positioning. Markets in apathy often precede breakout moves as new interest enters.
-1.5σ ≤ Z ≤ +2.0σ → NORMAL — positioning within typical range. - OI Oscillator (Saturation) — Stochastic-style normalization over 14 bars: . Ranges 0–100. Above 80 = OVERHEATED (near-term high in positioning). Below 20 = low saturation. Useful for shorter-term timing of OI extremes.
Pine Script® (oi - lowest(oi,14)) / (highest(oi,14) - lowest(oi,14)) * 100 - Crypto L/S Ratio (Binance Only) — Reads the long/short ratio via the _LSR suffix (e.g. BTCUSDT_LSR on Binance). When L/S > 2.0, the regime reads RETAIL FOMO — retail heavily skewed long, historically a contrarian warning. Below that = BALANCED. This mode only works with Binance perpetual symbols that provide LSR data.
Whale detection
On every bar, the indicator computes the change in OI and compares it to the highest OI inflow over the lookback period (default 100 bars). When the current inflow equals the highest inflow and is positive, a whale event triggers. Direction is determined by the candle:
- Green star (★) at the top = whale event on a bullish candle (close ≥ open) — large new positions entered during a price advance.
- Red star (★) at the top = whale event on a bearish candle (close < open) — large new positions entered during a price decline (likely new shorts or institutional hedges).
When bar coloring is enabled (default), whale bars render at full opacity to stand out from the regime-colored bars around them. This makes whale events immediately visible on any chart.
Multi-timeframe OI matrix
Three configurable timeframes (default: 1H, 4H, Daily) each pull OI data independently and compute the bar-over-bar delta. The dashboard shows each delta as a green (expanding) or red (contracting) value. This answers a critical question: is OI building on all timeframes, or just on the one you're watching?
Example: if 1H OI delta is positive but 4H and Daily are negative, the current OI build-up may be intraday noise, not a real positioning trend. When all three align green, the positioning signal is much stronger.
Squeeze and divergence signals
Both are off by default — enable them in Settings > Visuals.
- Squeeze alerts: Trigger when the Z-score is above +2.0σ (crowded) AND price prints a reversal candle (close < open for a long squeeze, close > open for a short squeeze). This combination — crowded positioning plus price rejection — is the classic setup for a positioning squeeze. A configurable cooldown (default 5 bars) prevents signal clustering.
- Divergence detection: Flags when price makes a new 5-bar high but the OI indicator value does not confirm (bearish divergence), or when price makes a new 5-bar low but OI stays elevated (bullish divergence). Plotted as triangles.
Dashboard terminal
A table (default: top-right) showing:
- Header row: active analysis mode
- Total Contracts: raw OI value
- Current Regime: regime label with color matching the plot
- MTF Delta: per-timeframe OI delta (green = expanding, red = contracting)
- Whale Activity: "DETECTED NOW" (with bull/bear color) or "Scanning..."
- Data Source: validation row — shows which OI source is connected, or "NO DATA" if no OI is available for the current symbol
Each dashboard section can be toggled on/off independently.
Data connection
Three modes for connecting to OI data:
- Auto Suffix (default): Appends "_OI" to the current symbol ticker. Works automatically on most crypto exchanges (e.g. BTCUSDT → BTCUSDT_OI on Binance). Also works on futures symbols where TradingView provides OI via suffix conventions.
- Manual Ticker: Enter any symbol manually. Use this for non-standard tickers or cross-exchange OI comparisons.
- Direct Symbol (Native): Uses the current chart symbol as-is, for instruments where OI is embedded directly in the data.
Key inputs and defaults
- Analysis Model: Statistical Z-Score (Sigma)
- Connection Mode: Auto Suffix (_OI)
- Whale Lookback: 100 bars
- Multi-TF Matrix: 60 min / 240 min / Daily
- Plot Style: Columns (also: Line, Area, Heatmap Gradient)
- Bar Coloring: enabled (whale events at full opacity)
- Squeeze Alerts / Divergences: off by default
- Signal Cooldown: 5 bars
- Dashboard: enabled, top-right
Plot styles
- Columns: Default. Color-coded vertical bars — best for spotting regime changes at a glance.
- Line: Continuous line — better for seeing trend direction of the indicator value.
- Area: Filled area plot with 40% transparency — emphasizes the magnitude.
- Heatmap Gradient: Same as columns but with gradient coloring — smoothest visual for Z-score mode.
Alerts
Two alert conditions available:
- MASTER ALERT: Fires on any squeeze or whale event (configurable via Settings > Alerts toggles).
- Whale Alert: Fires specifically on whale events (largest OI inflow over lookback period).
Limitations and shortcomings
- OI data availability depends entirely on the exchange and symbol. Not all instruments have _OI data on TradingView — the dashboard's status row will show "NO DATA" when OI is unavailable.
- Crypto L/S Ratio mode only works with Binance perpetual symbols that provide _LSR data. It will show zero for other exchanges.
- Whale detection flags the single largest bar-over-bar OI increase over the lookback. On low-volume instruments with erratic OI reporting, this may trigger on small absolute changes. Increase the lookback or disable whale stars for noisy symbols.
- The Z-score requires at least 100 bars of OI history to stabilize. On newly listed instruments or short lookbacks, early values may be unreliable.
- This is a positioning and regime indicator — it shows where contracts are building, not a standalone buy/sell system. Use with price action and risk management.
- No lookahead is used. The indicator does not repaint.
Works on any timeframe where OI data is available. Best on 1H, 4H, and Daily. Pine Script v5. Open source. MPL 2.0 | Robinhodl21
Skrip dilindungi
Skrip ini diterbitkan sebagai sumber tertutup. Akan tetapi, anda boleh menggunakannya secara bebas dan tanpa apa-apa had – ketahui lebih di sini.
Penafian
Maklumat dan penerbitan adalah tidak bertujuan, dan tidak membentuk, nasihat atau cadangan kewangan, pelaburan, dagangan atau jenis lain yang diberikan atau disahkan oleh TradingView. Baca lebih dalam Terma Penggunaan.
Skrip dilindungi
Skrip ini diterbitkan sebagai sumber tertutup. Akan tetapi, anda boleh menggunakannya secara bebas dan tanpa apa-apa had – ketahui lebih di sini.
Penafian
Maklumat dan penerbitan adalah tidak bertujuan, dan tidak membentuk, nasihat atau cadangan kewangan, pelaburan, dagangan atau jenis lain yang diberikan atau disahkan oleh TradingView. Baca lebih dalam Terma Penggunaan.