OPEN-SOURCE SCRIPT
Crypto Leverage Index(OI Norm. + FR)

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

* 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`.

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

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.

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

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.

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

⚪ 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.
(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`.
* 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`.
⚪ 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.
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.
4. Short Covering (Price ▲, OI ▼): Existing shorts are forced to close (Short Squeeze).
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.
6. Short Trap (Price ▼, OI ▲ or ▼): Warning Sign - Price falls, but OI suggests new positioning that might be trapping shorts.
⚪ 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.
开源脚本
秉承TradingView的精神,该脚本的作者将其开源,以便交易者可以查看和验证其功能。向作者致敬!您可以免费使用该脚本,但请记住,重新发布代码须遵守我们的网站规则。
免责声明
这些信息和出版物并非旨在提供,也不构成TradingView提供或认可的任何形式的财务、投资、交易或其他类型的建议或推荐。请阅读使用条款了解更多信息。
开源脚本
秉承TradingView的精神,该脚本的作者将其开源,以便交易者可以查看和验证其功能。向作者致敬!您可以免费使用该脚本,但请记住,重新发布代码须遵守我们的网站规则。
免责声明
这些信息和出版物并非旨在提供,也不构成TradingView提供或认可的任何形式的财务、投资、交易或其他类型的建议或推荐。请阅读使用条款了解更多信息。