OPEN-SOURCE SCRIPT
Rolling Correlation BTC vs Hedge Assets

Rolling Correlation BTC vs Hedge Assets
Overview
This indicator calculates and plots the rolling correlation between Bitcoin (BTC) returns and several key hedge assets:
• XAUUSD (Gold)
• EURUSD (proxy for DXY, U.S. Dollar Index)
• VIX (Volatility Index)
• TLT (20y U.S. Treasury Bonds ETF)
By monitoring these dynamic correlations, traders can identify whether BTC is moving in sync with risk assets or decoupling as a hedge, and adjust their trading strategy accordingly.
How it works
1. Computes returns for BTC and each asset using percentage change.
2. Uses the rolling correlation function (ta.correlation) over a configurable window length (default = 12 bars).
3. Plots each correlation as a separate colored line (Gold = Yellow, EURUSD = Blue, VIX = Red, TLT = Green).
4. Adds threshold levels at +0.3 and -0.3 to help classify correlation regimes.
How to use it
• High positive correlation (> +0.3): BTC is moving together with the asset (risk-on behavior).
• Near zero (-0.3 to +0.3): BTC is showing little to no correlation — neutral/independent moves.
• Negative correlation (< -0.3): BTC is moving in the opposite direction — potential hedge opportunity.
Practical strategies:
• Watch BTC vs VIX: a spike in volatility (VIX ↑) usually coincides with BTC selling pressure.
• Track BTC vs EURUSD: stronger USD often puts downside pressure on BTC.
• Observe BTC vs Gold: during “flight to safety” events, gold rises while BTC weakens.
• Monitor BTC vs TLT: rising yields (falling TLT) often align with BTC weakness.
Inputs
• Window Length (bars): Number of bars used to calculate rolling correlations (default = 12).
• Comparison Timeframe: Default = 5m. Can be changed to align with your intraday or swing trading style.
Notes
• Works best on intraday charts (1m, 5m, 15m) for scalping and short-term setups.
• Use correlations as context, not standalone signals — combine with volume, VWAP, and price action.
• Correlations are dynamic; they can switch regimes quickly during macro events (CPI, NFP, FOMC).
This tool is designed for traders who want to manage risk exposure by monitoring whether BTC is behaving as a risk-on asset or hedge, and to exploit opportunities during decoupling phases.
Overview
This indicator calculates and plots the rolling correlation between Bitcoin (BTC) returns and several key hedge assets:
• XAUUSD (Gold)
• EURUSD (proxy for DXY, U.S. Dollar Index)
• VIX (Volatility Index)
• TLT (20y U.S. Treasury Bonds ETF)
By monitoring these dynamic correlations, traders can identify whether BTC is moving in sync with risk assets or decoupling as a hedge, and adjust their trading strategy accordingly.
How it works
1. Computes returns for BTC and each asset using percentage change.
2. Uses the rolling correlation function (ta.correlation) over a configurable window length (default = 12 bars).
3. Plots each correlation as a separate colored line (Gold = Yellow, EURUSD = Blue, VIX = Red, TLT = Green).
4. Adds threshold levels at +0.3 and -0.3 to help classify correlation regimes.
How to use it
• High positive correlation (> +0.3): BTC is moving together with the asset (risk-on behavior).
• Near zero (-0.3 to +0.3): BTC is showing little to no correlation — neutral/independent moves.
• Negative correlation (< -0.3): BTC is moving in the opposite direction — potential hedge opportunity.
Practical strategies:
• Watch BTC vs VIX: a spike in volatility (VIX ↑) usually coincides with BTC selling pressure.
• Track BTC vs EURUSD: stronger USD often puts downside pressure on BTC.
• Observe BTC vs Gold: during “flight to safety” events, gold rises while BTC weakens.
• Monitor BTC vs TLT: rising yields (falling TLT) often align with BTC weakness.
Inputs
• Window Length (bars): Number of bars used to calculate rolling correlations (default = 12).
• Comparison Timeframe: Default = 5m. Can be changed to align with your intraday or swing trading style.
Notes
• Works best on intraday charts (1m, 5m, 15m) for scalping and short-term setups.
• Use correlations as context, not standalone signals — combine with volume, VWAP, and price action.
• Correlations are dynamic; they can switch regimes quickly during macro events (CPI, NFP, FOMC).
This tool is designed for traders who want to manage risk exposure by monitoring whether BTC is behaving as a risk-on asset or hedge, and to exploit opportunities during decoupling phases.
Skrip sumber terbuka
Dalam semangat sebenar TradingView, pencipta skrip ini telah menjadikannya sumber terbuka supaya pedagang dapat menilai dan mengesahkan kefungsiannya. Terima kasih kepada penulis! Walaupun anda boleh menggunakannya secara percuma, ingat bahawa menerbitkan semula kod ini adalah tertakluk kepada Peraturan Dalaman kami.
Penafian
Maklumat dan penerbitan adalah tidak dimaksudkan untuk menjadi, dan tidak membentuk, nasihat untuk kewangan, pelaburan, perdagangan dan jenis-jenis lain atau cadangan yang dibekalkan atau disahkan oleh TradingView. Baca dengan lebih lanjut di Terma Penggunaan.
Skrip sumber terbuka
Dalam semangat sebenar TradingView, pencipta skrip ini telah menjadikannya sumber terbuka supaya pedagang dapat menilai dan mengesahkan kefungsiannya. Terima kasih kepada penulis! Walaupun anda boleh menggunakannya secara percuma, ingat bahawa menerbitkan semula kod ini adalah tertakluk kepada Peraturan Dalaman kami.
Penafian
Maklumat dan penerbitan adalah tidak dimaksudkan untuk menjadi, dan tidak membentuk, nasihat untuk kewangan, pelaburan, perdagangan dan jenis-jenis lain atau cadangan yang dibekalkan atau disahkan oleh TradingView. Baca dengan lebih lanjut di Terma Penggunaan.