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. קרא עוד ב־תנאי השימוש.