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.
受保護腳本
此腳本以閉源形式發佈。 不過,您可以自由使用,沒有任何限制 — 點擊此處了解更多。
📊An all-in-one indicators dashboard is coming soon. Cryptocurrency market data analysis. TradingView indicator developer. Mensa member. Counter-trend scalping trader. Chart analysis and idea sharing.
免責聲明
這些資訊和出版物並非旨在提供,也不構成TradingView提供或認可的任何形式的財務、投資、交易或其他類型的建議或推薦。請閱讀使用條款以了解更多資訊。
受保護腳本
此腳本以閉源形式發佈。 不過,您可以自由使用,沒有任何限制 — 點擊此處了解更多。
📊An all-in-one indicators dashboard is coming soon. Cryptocurrency market data analysis. TradingView indicator developer. Mensa member. Counter-trend scalping trader. Chart analysis and idea sharing.
免責聲明
這些資訊和出版物並非旨在提供,也不構成TradingView提供或認可的任何形式的財務、投資、交易或其他類型的建議或推薦。請閱讀使用條款以了解更多資訊。