PROTECTED SOURCE SCRIPT
BTC Open interest (binance, bybit, okx, bitget, htx, deribit)

📈 BTC Open Interest Candles (Binance, Bybit, OKX, Bitget, HTX, Deribit)
🌟 Overview
This Pine Script indicator fetches real-time Bitcoin (BTC) perpetual futures open interest (OI) data from major cryptocurrency exchanges (Binance, OKX, Bybit, Bitget, HTX, Deribit), aggregates it, and visualizes it as candlesticks on the chart. Each candlestick represents the combined OI values at the open, high, low, and close of that bar. Candlestick colors change based on whether the current bar’s close OI is higher or lower than the previous bar’s, allowing intuitive tracking of OI fluctuations.
✨ Key Features
Multi-exchange OI aggregation: Combines OI data from selected exchanges to create a unified OI candlestick series.
Candlestick visualization: Converts aggregated OI values into open, high, low, and close values to plot candlestick charts, clearly showing the range and trend of OI over time.
Color-coded OI change:
Close OI higher than previous bar → teal candlestick (OI increase)
Close OI lower than previous bar → red candlestick (OI decrease)
⚙️ Inputs
📊 Calculation Methodology
Requests OI open, high, low, close values for the specified exchange using request.security().
Missing data (na) is treated as 0 to prevent aggregation errors.
Returns OI values as arrays.
➕ Aggregation of individual OI
Variables combinedOiOpen, combinedOiHigh, combinedOiLow, combinedOiClose initialized to 0.
Calls getOI for each enabled exchange and adds returned values to the combined variables.
🎨 Candlestick color determination
oiColorCond checks whether combinedOiClose > combinedOiClose[1].
True → openInterestColor = color.teal (OI increase)
False → openInterestColor = color.red (OI decrease)
🕯 Candlestick plotting
plotCandles ensures at least one exchange is selected.
plotcandle() is called with na values if no exchanges are selected to avoid drawing candles.
Candle body, wick, and border colors follow openInterestColor.
💡 How to Use
🌐 Integrated market sentiment
Observe overall market OI changes using a unified candlestick chart rather than fragmented exchange data to understand market sentiment and capital flow.
🔍 Compare with price movements
Analyze price charts alongside OI candlesticks to see how OI changes affect (or are affected by) price.
🟢 Price rising + teal OI candlestick (OI increase): Indicates bullish momentum from new long entries or short covering.
🔴 Price falling + red OI candlestick (OI decrease): Suggests bearish momentum from long liquidations or increased short covering.
📈 Price rising + red OI candlestick (OI decrease): Could reflect a short squeeze or profit-taking in long positions.
📉 Price falling + teal OI candlestick (OI increase): May indicate new short positions or forced long liquidations (stop-loss triggers).
⚡ Volatility prediction
Large OI candles or consecutive candles of a certain color can indicate imminent or ongoing significant market moves.
🌟 Overview
This Pine Script indicator fetches real-time Bitcoin (BTC) perpetual futures open interest (OI) data from major cryptocurrency exchanges (Binance, OKX, Bybit, Bitget, HTX, Deribit), aggregates it, and visualizes it as candlesticks on the chart. Each candlestick represents the combined OI values at the open, high, low, and close of that bar. Candlestick colors change based on whether the current bar’s close OI is higher or lower than the previous bar’s, allowing intuitive tracking of OI fluctuations.
✨ Key Features
Multi-exchange OI aggregation: Combines OI data from selected exchanges to create a unified OI candlestick series.
Candlestick visualization: Converts aggregated OI values into open, high, low, and close values to plot candlestick charts, clearly showing the range and trend of OI over time.
Color-coded OI change:
Close OI higher than previous bar → teal candlestick (OI increase)
Close OI lower than previous bar → red candlestick (OI decrease)
⚙️ Inputs
- Show Binance true Include Binance OI in the aggregation.
- Show OKX true Include OKX OI in the aggregation.
- Show Bybit true Include Bybit OI in the aggregation.
- Show Bitget true Include Bitget OI in the aggregation.
- Show HTX true Include HTX OI in the aggregation.
- Show Deribit true Include Deribit OI in the aggregation.
📊 Calculation Methodology
Requests OI open, high, low, close values for the specified exchange using request.security().
Missing data (na) is treated as 0 to prevent aggregation errors.
Returns OI values as arrays.
➕ Aggregation of individual OI
Variables combinedOiOpen, combinedOiHigh, combinedOiLow, combinedOiClose initialized to 0.
Calls getOI for each enabled exchange and adds returned values to the combined variables.
🎨 Candlestick color determination
oiColorCond checks whether combinedOiClose > combinedOiClose[1].
True → openInterestColor = color.teal (OI increase)
False → openInterestColor = color.red (OI decrease)
🕯 Candlestick plotting
plotCandles ensures at least one exchange is selected.
plotcandle() is called with na values if no exchanges are selected to avoid drawing candles.
Candle body, wick, and border colors follow openInterestColor.
💡 How to Use
🌐 Integrated market sentiment
Observe overall market OI changes using a unified candlestick chart rather than fragmented exchange data to understand market sentiment and capital flow.
🔍 Compare with price movements
Analyze price charts alongside OI candlesticks to see how OI changes affect (or are affected by) price.
🟢 Price rising + teal OI candlestick (OI increase): Indicates bullish momentum from new long entries or short covering.
🔴 Price falling + red OI candlestick (OI decrease): Suggests bearish momentum from long liquidations or increased short covering.
📈 Price rising + red OI candlestick (OI decrease): Could reflect a short squeeze or profit-taking in long positions.
📉 Price falling + teal OI candlestick (OI increase): May indicate new short positions or forced long liquidations (stop-loss triggers).
⚡ Volatility prediction
Large OI candles or consecutive candles of a certain color can indicate imminent or ongoing significant market moves.
Protected script
This script is published as closed-source. However, you can use it freely and without any limitations – learn more here.
Crypto trader. Scalping, counter-trend trading.
암호화폐 트레이더. 스캘핑, 역추세 매매.
펀딩비 급변동 텔레그램 알림
Signal of rapid change in funding rate : t.me/binanceFRsignal
암호화폐 트레이더. 스캘핑, 역추세 매매.
펀딩비 급변동 텔레그램 알림
Signal of rapid change in funding rate : t.me/binanceFRsignal
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.
Protected script
This script is published as closed-source. However, you can use it freely and without any limitations – learn more here.
Crypto trader. Scalping, counter-trend trading.
암호화폐 트레이더. 스캘핑, 역추세 매매.
펀딩비 급변동 텔레그램 알림
Signal of rapid change in funding rate : t.me/binanceFRsignal
암호화폐 트레이더. 스캘핑, 역추세 매매.
펀딩비 급변동 텔레그램 알림
Signal of rapid change in funding rate : t.me/binanceFRsignal
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.