OPEN-SOURCE SCRIPT

Regime Correlation Matrix

275
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.

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.