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.
오픈 소스 스크립트
트레이딩뷰의 진정한 정신에 따라, 이 스크립트의 작성자는 이를 오픈소스로 공개하여 트레이더들이 기능을 검토하고 검증할 수 있도록 했습니다. 작성자에게 찬사를 보냅니다! 이 코드는 무료로 사용할 수 있지만, 코드를 재게시하는 경우 하우스 룰이 적용된다는 점을 기억하세요.
면책사항
해당 정보와 게시물은 금융, 투자, 트레이딩 또는 기타 유형의 조언이나 권장 사항으로 간주되지 않으며, 트레이딩뷰에서 제공하거나 보증하는 것이 아닙니다. 자세한 내용은 이용 약관을 참조하세요.
오픈 소스 스크립트
트레이딩뷰의 진정한 정신에 따라, 이 스크립트의 작성자는 이를 오픈소스로 공개하여 트레이더들이 기능을 검토하고 검증할 수 있도록 했습니다. 작성자에게 찬사를 보냅니다! 이 코드는 무료로 사용할 수 있지만, 코드를 재게시하는 경우 하우스 룰이 적용된다는 점을 기억하세요.
면책사항
해당 정보와 게시물은 금융, 투자, 트레이딩 또는 기타 유형의 조언이나 권장 사항으로 간주되지 않으며, 트레이딩뷰에서 제공하거나 보증하는 것이 아닙니다. 자세한 내용은 이용 약관을 참조하세요.