OPEN-SOURCE SCRIPT
Mis à jour

Crypto Leverage Index(OI Norm. + FR)

1 774
Crypto Leverage Index (OI Z-Score + Funding Rate Signals)
(A tool for detecting speculative extremes and leverage load in crypto derivatives markets.)

Hello, fellow traders around the globe!
In today's crypto futures market, often perceived as a 'playground for large players' (whales/smart money), catching extreme leverage behavior is crucial for survival. I wanted to come up with an indicator to quickly identify such market extremes by focusing on the two most potent indicators of leveraged action: Open Interest (OI) and Funding Rate (FR). The goal is to ride on the shoulders of the market movers by anticipating their next liquidity-driven actions. hope this helps.

❗ IMPORTANT NOTE: This indicator works exclusively on Perpetual Futures or Swap Charts that provide Open Interest (OI) data.

⚪  Overview
This indicator provides a standardized view of speculative activity by calculating the Open Interest (OI) Z-Score. This score reveals when the current level of open leverage is abnormally high (premium) or low (discount) relative to its historical mean and volatility. The index is also augmented with Extreme Funding Rate Signals, which plot simple White Dots on the chart when derivative positioning (long or short bias) reaches an unsustainable, overheated level. The combination of OI volume and positioning bias offers a good method to identify potential market reversal zones driven by leverage liquidation risks (short/long squeezes).


⚪  Score Components
Open Interest Z-Score (Leverage Load)

The primary component standardizes the Open Interest value over a defined lookback `Period` (default 50). This calculation reveals the statistical deviation of current leverage from the norm.

OI Z-Score = (OI - Mean(OI)) / StDev(OI)

Funding Rate (Positioning Bias)

Calculates the approximate funding rate using a TWAP (Time-Weighted Average Price) of the Perpetual Futures Premium, combined with the standard 0.01% Interest Rate.


⚪  Extreme Condition Detection
OI Z-Score Extremes

* Premium Zone (Red Fill): OI Z-Score is above the user-defined `Threshold` (default 2.0). Indicates high/overstretched leverage.

* Discount Zone (Green Fill): OI Z-Score is below the user-defined negative threshold (default -2.0). Indicates low/unwinded leverage.

Funding Rate Extreme Signals (White Dots)

These appear as small White Dots ( · ) plotted at fixed levels within the indicator pane. The position indicates the bias:

* Top Dot (Excessive Longs): Triggered when Funding Rate is greater than Abnormal Funding Rate Threshold (e.g. 0.03%). Indicates excessive Long positioning/greed and potential for a short-term reversal (Long Squeeze risk). The dot is plotted at the positive `FR Signal Plot Level`.
snapshot

* Bottom Dot (Excessive Shorts): Triggered when Funding Rate is lower than -Abnormal Funding Rate Threshold(e.g. -0.03%). Indicates excessive Short positioning/fear and potential for a short-term reversal (Short Squeeze risk). The dot is plotted at the negative `FR Signal Plot Level`.
snapshot


⚪  Leverage Case Scenarios (Price, OI Dynamics & Context)
The OI Z-Score reflects the premium/discount state of *leverage* (Open Interest), not the price. The price may not be in a premium or discount area simply because the OI is. OI only indicates the volume of outstanding futures positions. You must observe price action and candlestick patterns alongside the OI movements to determine the true contextual hint. Understanding the relationship between price and Open Interest (OI) change is key to interpreting market movements. The cases listed below represent the most common and thinkable patterns, but do not exhaust all possible market behaviors.

1. Long Build-Up (Price ▲, OI ▲): New long positions enter, confirming the rising trend.
snapshot

2. Short Build-Up (Price ▼, OI ▲): New short positions enter, confirming the falling trend. Due to the inherently long-biased nature of the crypto market, this scenario is less frequently observed than Long Build-Up.

3. Long Covering/liquidation (Price ▼, OI ▼): Existing longs are closed/liquidated. This activity usually results from Panic Selling or forced long liquidation.
snapshot

4. Short Covering (Price ▲, OI ▼): Existing shorts are forced to close (Short Squeeze).
snapshot

5. Long Trap (Price ▲, OI ▲ or ▼): Price rises, but OI suggests new positioning that might be trapping longs. Bearish candle pattern can be often shown with the sweep.
snapshot

6. Short Trap (Price ▼, OI ▲ or ▼): Warning Sign - Price falls, but OI suggests new positioning that might be trapping shorts.
snapshot


⚪  Key Input Parameters
OI Z-Score
* Period (Default: 50)
Determines how many recent bars are used to calculate the rolling mean and volatility (standard deviation) of the Open Interest data.

* Z-Score Threshold (Default: 2.0)
The critical level that the OI Z-Score must cross to be considered 'extreme' (overstretched leverage).

Funding Rate
* Abnormal FR Threshold (Default: 0.03)
The absolute percentage value (e.g., 0.03%) that the Funding Rate must exceed or fall below to trigger an extreme signal dot.

* FR Signal Plot Level (Default: 4.0)
Sets the fixed vertical position (Y-level) on the Z-Score chart where the Funding Rate signal dots will appear. (e.g., 4.0 plots the dot at the Z-Score +-4.0 level).


Disclaimer
This script is for educational and informational purposes only and does not constitute financial advice or investment recommendations. Trading cryptocurrencies involves significant risk and you are solely responsible for your own investment decisions, based on your financial situation, objectives, and risk tolerance. The author assumes no liability for losses arising from the use of this indicator.
Notes de version
Added a feature that displays white dots(for high low OI) or cross(for high low FR). It is by default off and can be turned on in the setting.
snapshot
Notes de version
Update 1: general code refactoring.

Update 2: Multi-Exchange OI Consensus Logic


This update refines how Open Interest (OI) extremes are evaluated by introducing a multi-exchange consensus filter. OI spikes on a single exchange can be misleading or noisy. By requiring confirmation across multiple venues, this update focuses on market-wide leverage positioning rather than isolated anomalies. I thought it could give an extra edge if well used. Hope you like it.

Overview
OI Z-Score extremes are now checked across multiple major futures exchanges:

Binance
OKX
Bybit
The current chart exchange (always included)

The goal is to reduce exchange-specific noise and highlight OI extremes that appear consistently across the market.

Consensus Mechanism
Each exchange contributes one count when its OI Z-Score exceeds the defined threshold.
Exchanges that do not provide OI data for the current symbol are automatically ignored.
A consensus is formed when the number of exchanges meeting the condition reaches the user-defined minimum.

The minimum required count is controlled by the setting:
Consensus Min Count
Higher values require broader confirmation and produce fewer signals.
Lower values allow earlier detection but may include more noise.

Visualization Changes
snapshot
The OI Z-Score of the current ticker remains the primary plotted series.
When a consensus condition is met, the OI Z-Score is displayed with stronger visual emphasis.
Non-consensus OI extremes are still shown but with reduced visibility with transparency applied.
- Plot : multi exchange confirmed - strong red/green think line. current ticker confirmed: transparent red/green thin line.
- Chart: multi exchange confirmed - white dot. current ticker confirmed: transparent white dot(like gray color)

Clause de non-responsabilité

Les informations et publications ne sont pas destinées à être, et ne constituent pas, des conseils ou recommandations financiers, d'investissement, de trading ou autres fournis ou approuvés par TradingView. Pour en savoir plus, consultez les Conditions d'utilisation.