OPEN-SOURCE SCRIPT
Gold Macro Regime (DXY + VIX)

Here you go — written for TradingView's publish format:
Gold Macro Regime (DXY + VIX)
A dual-axis macro regime indicator for XAUUSD that uses the US Dollar Index (DXY) and CBOE Volatility Index (VIX) as independent signal channels to classify gold's macro environment and generate mean-reversion trade signals.
How It Works
The indicator computes rolling z-scores for both DXY (inverted, so positive = dollar weakening = gold-bullish) and VIX (positive = fear rising = safe-haven bid for gold). These two axes create a four-quadrant regime map:
🟢 Gold Bull — DXY falling + VIX rising (weak dollar + fear = strongest gold tailwind)
🟡 Haven Test — DXY rising + VIX rising (dollar strength vs. fear bid — ambiguous)
🔵 Goldilocks — DXY falling + VIX falling (risk-on with mild gold drift higher)
🔴 Headwind — DXY rising + VIX falling (strong dollar + complacency = gold's worst regime)
Dual-Confirmation Signals
Unlike single-input indicators, signals only fire when both z-scores cross the threshold simultaneously. LONG when both DXY(inv) and VIX z-scores exceed +1.0 (dollar weakening into a fear spike). SHORT when both drop below −1.0 (dollar strengthening into complacency). This dual gate filters out noise from single-axis moves.
Correlation Confidence Filter
Because DXY and VIX are exogenous to gold (unlike implied volatility on its own underlying), the historical relationships can temporarily break down — for example, when real rates dominate the gold narrative over dollar direction. The indicator tracks rolling correlations for DXY↔Gold (expected negative) and VIX↔Gold (expected positive), computing a confidence score. When correlations are behaving normally, signals fire at full strength. When either decorrelates, signals are dimmed or suppressed entirely, with "×" markers showing what would have triggered. This is toggleable between hard gating and info-only display.
Features
Independent DXY and VIX z-score lines with configurable lookback (default 60)
Four-quadrant background regime shading
Dual-confirmed LONG/SHORT arrows color-coded by correlation confidence (bright = high, faded = medium)
Spike/crush detection for sudden DXY or VIX moves (2σ single-bar events)
Optional composite score overlay (average of both z-scores)
Optional rolling correlation plot lines
Info table: DXY, VIX, both z-scores, composite, both correlations, confidence %, current quadrant, signal state, and XAUUSD price
Full alert suite: dual-confirm long/short, bull/bear spike events, correlation breakdown, and quadrant transitions
Suggested Use
Apply to a daily XAUUSD chart. The indicator is designed as a regime awareness and signal overlay — use the quadrant classification to contextualize price action and the dual-confirmed signals as high-conviction entries. The correlation confidence filter helps you know when to trust the signals and when the macro relationships have shifted. Best paired with price-level tools (support/resistance, volume profile) for entry refinement.
Gold Macro Regime (DXY + VIX)
A dual-axis macro regime indicator for XAUUSD that uses the US Dollar Index (DXY) and CBOE Volatility Index (VIX) as independent signal channels to classify gold's macro environment and generate mean-reversion trade signals.
How It Works
The indicator computes rolling z-scores for both DXY (inverted, so positive = dollar weakening = gold-bullish) and VIX (positive = fear rising = safe-haven bid for gold). These two axes create a four-quadrant regime map:
🟢 Gold Bull — DXY falling + VIX rising (weak dollar + fear = strongest gold tailwind)
🟡 Haven Test — DXY rising + VIX rising (dollar strength vs. fear bid — ambiguous)
🔵 Goldilocks — DXY falling + VIX falling (risk-on with mild gold drift higher)
🔴 Headwind — DXY rising + VIX falling (strong dollar + complacency = gold's worst regime)
Dual-Confirmation Signals
Unlike single-input indicators, signals only fire when both z-scores cross the threshold simultaneously. LONG when both DXY(inv) and VIX z-scores exceed +1.0 (dollar weakening into a fear spike). SHORT when both drop below −1.0 (dollar strengthening into complacency). This dual gate filters out noise from single-axis moves.
Correlation Confidence Filter
Because DXY and VIX are exogenous to gold (unlike implied volatility on its own underlying), the historical relationships can temporarily break down — for example, when real rates dominate the gold narrative over dollar direction. The indicator tracks rolling correlations for DXY↔Gold (expected negative) and VIX↔Gold (expected positive), computing a confidence score. When correlations are behaving normally, signals fire at full strength. When either decorrelates, signals are dimmed or suppressed entirely, with "×" markers showing what would have triggered. This is toggleable between hard gating and info-only display.
Features
Independent DXY and VIX z-score lines with configurable lookback (default 60)
Four-quadrant background regime shading
Dual-confirmed LONG/SHORT arrows color-coded by correlation confidence (bright = high, faded = medium)
Spike/crush detection for sudden DXY or VIX moves (2σ single-bar events)
Optional composite score overlay (average of both z-scores)
Optional rolling correlation plot lines
Info table: DXY, VIX, both z-scores, composite, both correlations, confidence %, current quadrant, signal state, and XAUUSD price
Full alert suite: dual-confirm long/short, bull/bear spike events, correlation breakdown, and quadrant transitions
Suggested Use
Apply to a daily XAUUSD chart. The indicator is designed as a regime awareness and signal overlay — use the quadrant classification to contextualize price action and the dual-confirmed signals as high-conviction entries. The correlation confidence filter helps you know when to trust the signals and when the macro relationships have shifted. Best paired with price-level tools (support/resistance, volume profile) for entry refinement.
开源脚本
秉承TradingView的精神,该脚本的作者将其开源,以便交易者可以查看和验证其功能。向作者致敬!您可以免费使用该脚本,但请记住,重新发布代码须遵守我们的网站规则。
免责声明
这些信息和出版物并非旨在提供,也不构成TradingView提供或认可的任何形式的财务、投资、交易或其他类型的建议或推荐。请阅读使用条款了解更多信息。
开源脚本
秉承TradingView的精神,该脚本的作者将其开源,以便交易者可以查看和验证其功能。向作者致敬!您可以免费使用该脚本,但请记住,重新发布代码须遵守我们的网站规则。
免责声明
这些信息和出版物并非旨在提供,也不构成TradingView提供或认可的任何形式的财务、投资、交易或其他类型的建议或推荐。请阅读使用条款了解更多信息。