OPEN-SOURCE SCRIPT

OI & CVD Master: Market Microstructure Analyzer

153
🇬🇧 English Description
Introduction
Price action tells you where the market went, but Volume and Open Interest (OI) tell you why it went there. This indicator combines Open Interest (OI) and Cumulative Volume Delta (CVD) to visualize market microstructure. By analyzing the correlation between money flow (OI) and buying/selling pressure (CVD), it categorizes the market into 4 distinct states, helping traders identify institutional intent.
How it Works (The Logic)
The script compares the percentage change of smoothed OI and CVD against a filter threshold to determine the current regime:
🟢 Long Build (Aggressive Buying):
Logic: CVD ↗️ AND OI ↗️
Meaning: Traders are aggressively buying to open new long positions. Strong bullish signal.
🔴 Short Build (Aggressive Selling):
Logic: CVD ↘️ AND OI ↗️
Meaning: Traders are aggressively selling to open new short positions. Top formation or bearish continuation.
🔵 Short Liquidation (Short Squeeze):
Logic: CVD ↗️ AND OI ↘️
Meaning: Price is rising because shorts are closing positions (buying back), not because of new bulls. Often leads to a reversal after the squeeze.
🟠 Long Liquidation (Panic Selling):
Logic: CVD ↘️ AND OI ↘️
Meaning: Price is dropping because longs are closing positions (stop losses hit). A "Long Squeeze" or "Long Puke."
Key Features
Auto-OI Detection: Automatically finds the correct _OI or _P_OI ticker for the current chart (best for Crypto Futures).
Dual CVD Modes:
Real CVD: Connects to external data sources if available.
Simulated CVD (Optimized): A proprietary algorithm that estimates buy/sell pressure based on candle shape (OHLC) and volume, specifically weighted for Doji candles.
Data Dashboard: A table displaying real-time values, change rates, and the current market state.
Visual Overlay: Background colors change dynamically to reflect the market state.
Usage Tips
Best Timeframes: 15m, 1h, 4h.
Symbol: This indicator works best on Perpetual Futures contracts (e.g., BTCUSDT.P), as Spot markets do not have Open Interest data.
Threshold: Adjust the Threshold % setting to filter out noise in low-volatility markets.
🇨🇳 中文说明
简介
价格告诉我们市场去了哪里,而持仓量(OI)和成交量告诉我们市场为什么去那里。本指标结合了 持仓量 (Open Interest) 和 累积成交量增量 (CVD),旨在分析市场的微观结构。通过分析资金流向(OI)与买卖压力(CVD)之间的相关性,将市场划分为 4 种状态,帮助交易者识别主力资金的真实意图。
核心逻辑 (如何解读)
脚本计算平滑后的 OI 和 CVD 变化率,并根据以下逻辑判断市场状态:
🟢 多头建仓 (Long Build):
逻辑: CVD 上升 ↗️ + OI 上升 ↗️
含义: 资金主动买入开多。这是最强的看涨信号,表明有新资金进场推升价格。
🔴 空头建仓 (Short Build):
逻辑: CVD 下降 ↘️ + OI 上升 ↗️
含义: 资金主动卖出开空。通常出现在顶部或下跌中继,表明大户正在吸筹做空。
🔵 空头平仓 (Short Liquidations / 逼空):
逻辑: CVD 上升 ↗️ + OI 下降 ↘️
含义: 价格上涨是因为空头止损离场(被动买入),而非多头主动买入。这种上涨通常不可持续。
🟠 多头平仓 (Long Liquidations / 多杀多):
逻辑: CVD 下降 ↘️ + OI 下降 ↘️
含义: 价格下跌是因为多头止损离场(被动卖出)。通常发生在剧烈回调或崩盘中。
主要功能
智能 OI 获取: 自动识别当前交易对并尝试获取 _OI 或 _P_OI 数据(适用于加密货币合约)。
双模式 CVD:
外部源: 支持输入特定代码获取真实 CVD。
模拟算法: 内置优化的估算算法,根据 K 线形态(OHLC)和成交量加权计算买卖压力,比单纯的 Up/Down Volume 更精准。
信息面板: 图表右上方实时显示当前 CVD、OI 数值、变化率及市场状态。
视觉增强: 背景颜色随市场状态动态变化,直观展示多空博弈结果。
使用建议
适用市场: 请在 永续合约 图表上使用(如 BTCUSDT.P),只有合约才有持仓量数据。
参数调整: 如果市场震荡剧烈,可适当调大“变化阈值%”以过滤噪音信号。

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.