OPEN-SOURCE SCRIPT

XAU Macro Regime + Mispricing Oscillator

52
This indicator is designed to measure the true macro environment behind gold (XAUUSD) and identify when price is aligned with macro flows or mispriced relative to them.
It combines a macro composite index, a mispricing spread oscillator, and automatic divergence detection into one tool.

1. Macro Composite Index (Regime Filter)

The top layer of the indicator constructs a macro regime score derived from:
A basket of gold FX pairs (XAUJPY, XAUAUD, XAUCHF, XAUNZD, XAUSGD)
The inverted DXY (to represent USD pressure on gold)
US30 (to capture global risk appetite and macro sentiment)
Each component is normalized and weighted, then combined into a composite macro index.
A smoothed baseline (SMA) is subtracted from this composite to form the Regime Line.

Interpretation

Regime > 0 (Green background):
Macro environment is supportive for gold.
XAUUSD is more likely to rise, consolidate, or mean revert upward.

Regime < 0 (Red background):
Macro environment is hostile for gold.
XAUUSD is more likely to fall, struggle, or mean revert downward.

This creates a macro trend filter that tells you when it is safer to prefer longs, shorts, or stay out.

2. Mispricing Spread Oscillator (Spread MACD)

The second layer measures the difference between XAUUSD and the macro composite index:
Spread = (Macro Composite) – (Normalized XAUUSD)


This spread is then smoothed into a signal line, and a histogram is plotted from their difference (MACD-style).

Interpretation

Spread > 0:
Gold is undervalued relative to macro conditions.
Macro strength > price strength.

Spread < 0:
Gold is overvalued relative to macro conditions.
Price strength > macro strength.

Spread crossing above signal:
Macro momentum turning bullish relative to price.

Spread crossing below signal:
Macro momentum turning bearish relative to price.

Green histogram: acceleration upward
Red histogram: acceleration downward

This oscillator captures mispricing, momentum shifts, and macro-pressure reversals.

3. Automatic Divergence Detection

The indicator automatically detects:

-Bullish Divergence-

XAUUSD makes a lower low

Spread makes a higher low
→ Price is weaker than macro reality → potential bullish reversal or mispricing reversion.

-Bearish Divergence-

XAUUSD makes a higher high

Spread makes a lower high
→ Price is stronger than macro reality → potential bearish reversal or exhaustion.

Labels (“Bull div” / “Bear div”) appear directly on the oscillator for clarity.

4. What The Indicator Seeks To Do

This indicator aims to answer the question:

“Is gold moving with the true macro pressure behind it, or diverging from it?”

Most gold indicators only watch XAUUSD price.

This one watches:
-gold cross-currency flows
-USD strength
-global risk sentiment
-gold’s relative position vs macro
-mispricing momentum
-divergence between price and macro reality

This creates a unique tool that:
-Detects when gold is overextended
-Detects when gold is undervalued
-Reveals hidden macro strength or weakness
-Highlights turning points and exhaustion
-Shows when a pullback is likely to end
-Shows when a rally is likely to fail
-Gives regime-aware trade direction (long vs short bias)
-Adds divergence labels for precision entries

면책사항

해당 정보와 게시물은 금융, 투자, 트레이딩 또는 기타 유형의 조언이나 권장 사항으로 간주되지 않으며, 트레이딩뷰에서 제공하거나 보증하는 것이 아닙니다. 자세한 내용은 이용 약관을 참조하세요.