OPEN-SOURCE SCRIPT
Regime Correlation Matrix

Regime Correlation Matrix — TradingView Indicator
This indicator displays a real-time rolling Pearson correlation table between NQ (or any base chart symbol) and seven macro instruments: ES, CL (Crude Oil), 6C (Canadian Dollar), HG (Copper), GC (Gold), ZN (10-Year Treasury), and USD/CNH (Offshore Chinese Yuan). Each row shows the correlation coefficient, a dot-strength rating, and an auto-generated regime interpretation label.
Designed for intraday regime diagnosis. The default length of 78 bars covers one full RTH session on a 5-minute chart. Reducing to 20 bars produces a responsive rolling 2-hour window for real-time session reads. Increasing to 390 bars covers a full trading week for macro regime-level analysis.
Color coding: Bright green = strong positive correlation (r ≥ 0.6). Faded green = weak positive (r ≥ 0.2). Bright red = strong negative (r ≤ -0.6). Faded red = weak negative (r ≤ -0.2). Gray = neutral / no meaningful correlation.
Regime interpretation logic is instrument-specific:
CL: positive correlation = risk-on or geopolitical supply bid. Negative = stagflation regime, CL is the headwind.
6C: positive = tariff relief being priced. Negative = tariff fear active.
HG (Copper): positive = global growth and trade normalization. Negative = demand destruction.
GC (Gold): negative correlation to equities = uncertainty bid active, market does not trust the rally.
ZN (Bonds): negative = inflation/risk-on. Positive = deflation/risk-off flight to safety.
USD/CNH: this row is inverse — USD/CNH rising means CNH is weakening, meaning tariff fear is active. A negative correlation between NQ and USD/CNH therefore signals tariff relief. The regime label accounts for this inversion automatically.
ES: correlation to NQ reads index cohesion. Below 0.6 flags potential decoupling. Readings below 0.2 trigger a DECOUPLED label — the primary signal that session precision will be degraded and size should be reduced.
Primary use cases: Pre-session regime check, intraday regime shift detection, confirmation before adding size to a directional position, and identification of decoupled sessions where full-size trading is inappropriate. The footer row displays the current bar length, timeframe, and base symbol so the context is always visible at a glance.
This indicator displays a real-time rolling Pearson correlation table between NQ (or any base chart symbol) and seven macro instruments: ES, CL (Crude Oil), 6C (Canadian Dollar), HG (Copper), GC (Gold), ZN (10-Year Treasury), and USD/CNH (Offshore Chinese Yuan). Each row shows the correlation coefficient, a dot-strength rating, and an auto-generated regime interpretation label.
Designed for intraday regime diagnosis. The default length of 78 bars covers one full RTH session on a 5-minute chart. Reducing to 20 bars produces a responsive rolling 2-hour window for real-time session reads. Increasing to 390 bars covers a full trading week for macro regime-level analysis.
Color coding: Bright green = strong positive correlation (r ≥ 0.6). Faded green = weak positive (r ≥ 0.2). Bright red = strong negative (r ≤ -0.6). Faded red = weak negative (r ≤ -0.2). Gray = neutral / no meaningful correlation.
Regime interpretation logic is instrument-specific:
CL: positive correlation = risk-on or geopolitical supply bid. Negative = stagflation regime, CL is the headwind.
6C: positive = tariff relief being priced. Negative = tariff fear active.
HG (Copper): positive = global growth and trade normalization. Negative = demand destruction.
GC (Gold): negative correlation to equities = uncertainty bid active, market does not trust the rally.
ZN (Bonds): negative = inflation/risk-on. Positive = deflation/risk-off flight to safety.
USD/CNH: this row is inverse — USD/CNH rising means CNH is weakening, meaning tariff fear is active. A negative correlation between NQ and USD/CNH therefore signals tariff relief. The regime label accounts for this inversion automatically.
ES: correlation to NQ reads index cohesion. Below 0.6 flags potential decoupling. Readings below 0.2 trigger a DECOUPLED label — the primary signal that session precision will be degraded and size should be reduced.
Primary use cases: Pre-session regime check, intraday regime shift detection, confirmation before adding size to a directional position, and identification of decoupled sessions where full-size trading is inappropriate. The footer row displays the current bar length, timeframe, and base symbol so the context is always visible at a glance.
Skrip sumber terbuka
Dalam semangat TradingView sebenar, pencipta skrip ini telah menjadikannya sumber terbuka, jadi pedagang boleh menilai dan mengesahkan kefungsiannya. Terima kasih kepada penulis! Walaupuan anda boleh menggunakan secara percuma, ingat bahawa penerbitan semula kod ini tertakluk kepada Peraturan Dalaman.
Penafian
Maklumat dan penerbitan adalah tidak bertujuan, dan tidak membentuk, nasihat atau cadangan kewangan, pelaburan, dagangan atau jenis lain yang diberikan atau disahkan oleh TradingView. Baca lebih dalam Terma Penggunaan.
Skrip sumber terbuka
Dalam semangat TradingView sebenar, pencipta skrip ini telah menjadikannya sumber terbuka, jadi pedagang boleh menilai dan mengesahkan kefungsiannya. Terima kasih kepada penulis! Walaupuan anda boleh menggunakan secara percuma, ingat bahawa penerbitan semula kod ini tertakluk kepada Peraturan Dalaman.
Penafian
Maklumat dan penerbitan adalah tidak bertujuan, dan tidak membentuk, nasihat atau cadangan kewangan, pelaburan, dagangan atau jenis lain yang diberikan atau disahkan oleh TradingView. Baca lebih dalam Terma Penggunaan.