OPEN-SOURCE SCRIPT
BTC Spot vs Perpetual CVD Divergence

This indicator:
Data Sources:
CVD Approximation:
Since true CVD requires order book data (not fully available in Pine Script), we approximate it by:
Normalization:
Divergence Calculation:
Visualization:
Limitations:
This is an approximation since true CVD requires buy/sell volume separation, which isn't directly available
Results may vary depending on timeframe and lookback period
Assumes volume data reliability from both markets
Data Sources:
- Uses Binance BTC/USDT for spot market
- Uses Binance BTC/USD perpetual (USD-M) for futures market
- Both symbols should be available on TradingView
CVD Approximation:
Since true CVD requires order book data (not fully available in Pine Script), we approximate it by:
- Multiplying volume by price direction (+1 for up bars, -1 for down bars)
- Summing over the specified lookback period
Normalization:
- Normalizes both CVD values to a -1 to 1 range for fair comparison
- This accounts for different volume scales between spot and perpetual markets
Divergence Calculation:
- Subtracts normalized perpetual CVD from spot CVD
- Positive values indicate spot market is more bullish than perpetual
- Negative values indicate perpetual market is more bullish than spot
Visualization:
- Red line: Main divergence indicator
- Green line: Normalized spot CVD
- Blue line: Normalized perpetual CVD
- Green background: Strong positive divergence (>0.5)
- Red background: Strong negative divergence (<-0.5)
- Gray dashed line at zero
Limitations:
This is an approximation since true CVD requires buy/sell volume separation, which isn't directly available
Results may vary depending on timeframe and lookback period
Assumes volume data reliability from both markets
نص برمجي مفتوح المصدر
بروح TradingView الحقيقية، قام مبتكر هذا النص البرمجي بجعله مفتوح المصدر، بحيث يمكن للمتداولين مراجعة وظائفه والتحقق منها. شكرا للمؤلف! بينما يمكنك استخدامه مجانًا، تذكر أن إعادة نشر الكود يخضع لقواعد الموقع الخاصة بنا.
إخلاء المسؤولية
لا يُقصد بالمعلومات والمنشورات أن تكون، أو تشكل، أي نصيحة مالية أو استثمارية أو تجارية أو أنواع أخرى من النصائح أو التوصيات المقدمة أو المعتمدة من TradingView. اقرأ المزيد في شروط الاستخدام.
نص برمجي مفتوح المصدر
بروح TradingView الحقيقية، قام مبتكر هذا النص البرمجي بجعله مفتوح المصدر، بحيث يمكن للمتداولين مراجعة وظائفه والتحقق منها. شكرا للمؤلف! بينما يمكنك استخدامه مجانًا، تذكر أن إعادة نشر الكود يخضع لقواعد الموقع الخاصة بنا.
إخلاء المسؤولية
لا يُقصد بالمعلومات والمنشورات أن تكون، أو تشكل، أي نصيحة مالية أو استثمارية أو تجارية أو أنواع أخرى من النصائح أو التوصيات المقدمة أو المعتمدة من TradingView. اقرأ المزيد في شروط الاستخدام.