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.
开源脚本
秉承TradingView的精神,该脚本的作者将其开源,以便交易者可以查看和验证其功能。向作者致敬!您可以免费使用该脚本,但请记住,重新发布代码须遵守我们的网站规则。
免责声明
这些信息和出版物并非旨在提供,也不构成TradingView提供或认可的任何形式的财务、投资、交易或其他类型的建议或推荐。请阅读使用条款了解更多信息。
开源脚本
秉承TradingView的精神,该脚本的作者将其开源,以便交易者可以查看和验证其功能。向作者致敬!您可以免费使用该脚本,但请记住,重新发布代码须遵守我们的网站规则。
免责声明
这些信息和出版物并非旨在提供,也不构成TradingView提供或认可的任何形式的财务、投资、交易或其他类型的建议或推荐。请阅读使用条款了解更多信息。