OPEN-SOURCE SCRIPT
Real Yields vs Gold vs DXY

This indicator overlays U.S. real yields, gold prices, and the U.S. Dollar Index (DXY) on the same chart, with optional normalization (raw values, Z-Score, or % change since start). It pulls macroeconomic data directly from the Federal Reserve Economic Data (FRED) (TIPS yields, nominal Treasuries, and breakeven inflation) and compares it against market feeds for gold and the dollar.
⸻
📌 What it shows you
1. Real Yields (teal line):
• The inflation-adjusted interest rate.
• Higher real yields typically reduce gold’s appeal (since gold doesn’t yield anything).
• Lower real yields usually support gold, as holding non-yielding assets becomes more attractive.
2. Gold (orange line, with optional MA):
• Spot gold (or futures) price series.
• Often moves inversely to real yields, but can diverge when inflation fears or safe-haven demand dominate.
3. U.S. Dollar Index (DXY) (blue line):
• The strength of the U.S. dollar versus major currencies.
• A strong USD often pressures gold (since it’s priced in dollars).
• Weakness in the USD often supports gold.
4. Reference Lines (0, +3, –3):
• In Z-Score mode, these act as statistical boundaries.
• Movements beyond +3 or –3 standard deviations usually signal extreme, unsustainable conditions.
📌 Why it matters for macro outlook
This indicator lets you see the three most important macro forces on gold in one pane:
• Real yields → reflect Fed policy, inflation expectations, and bond market pricing.
• DXY → reflects capital flows into or out of the USD.
• Gold → reacts to both, serving as a hedge, safe-haven, or inflation play.
By watching how these move together or diverge, you can answer key macro questions:
• Is gold moving inversely to real yields (normal regime)?
• Is gold rising even when real yields rise (inflation stress or risk aversion)?
• Is the dollar breaking the relationship (e.g., strong USD pushing gold lower despite falling yields)?
• Are we at statistical extremes (beyond ±3 Z-score), signaling stretched positioning?
⸻
✅ In short: This indicator is a macro overlay tool. It tells the story of how bond markets (real yields), currency markets (USD), and commodities (gold) interact — and whether gold’s behavior is consistent with macro fundamentals or signaling something unusual.
⸻
📌 What it shows you
1. Real Yields (teal line):
• The inflation-adjusted interest rate.
• Higher real yields typically reduce gold’s appeal (since gold doesn’t yield anything).
• Lower real yields usually support gold, as holding non-yielding assets becomes more attractive.
2. Gold (orange line, with optional MA):
• Spot gold (or futures) price series.
• Often moves inversely to real yields, but can diverge when inflation fears or safe-haven demand dominate.
3. U.S. Dollar Index (DXY) (blue line):
• The strength of the U.S. dollar versus major currencies.
• A strong USD often pressures gold (since it’s priced in dollars).
• Weakness in the USD often supports gold.
4. Reference Lines (0, +3, –3):
• In Z-Score mode, these act as statistical boundaries.
• Movements beyond +3 or –3 standard deviations usually signal extreme, unsustainable conditions.
📌 Why it matters for macro outlook
This indicator lets you see the three most important macro forces on gold in one pane:
• Real yields → reflect Fed policy, inflation expectations, and bond market pricing.
• DXY → reflects capital flows into or out of the USD.
• Gold → reacts to both, serving as a hedge, safe-haven, or inflation play.
By watching how these move together or diverge, you can answer key macro questions:
• Is gold moving inversely to real yields (normal regime)?
• Is gold rising even when real yields rise (inflation stress or risk aversion)?
• Is the dollar breaking the relationship (e.g., strong USD pushing gold lower despite falling yields)?
• Are we at statistical extremes (beyond ±3 Z-score), signaling stretched positioning?
⸻
✅ In short: This indicator is a macro overlay tool. It tells the story of how bond markets (real yields), currency markets (USD), and commodities (gold) interact — and whether gold’s behavior is consistent with macro fundamentals or signaling something unusual.
Skrip sumber terbuka
Dalam semangat sebenar TradingView, pencipta skrip ini telah menjadikannya sumber terbuka supaya pedagang dapat menilai dan mengesahkan kefungsiannya. Terima kasih kepada penulis! Walaupun anda boleh menggunakannya secara percuma, ingat bahawa menerbitkan semula kod ini adalah tertakluk kepada Peraturan Dalaman kami.
Penafian
Maklumat dan penerbitan adalah tidak dimaksudkan untuk menjadi, dan tidak membentuk, nasihat untuk kewangan, pelaburan, perdagangan dan jenis-jenis lain atau cadangan yang dibekalkan atau disahkan oleh TradingView. Baca dengan lebih lanjut di Terma Penggunaan.
Skrip sumber terbuka
Dalam semangat sebenar TradingView, pencipta skrip ini telah menjadikannya sumber terbuka supaya pedagang dapat menilai dan mengesahkan kefungsiannya. Terima kasih kepada penulis! Walaupun anda boleh menggunakannya secara percuma, ingat bahawa menerbitkan semula kod ini adalah tertakluk kepada Peraturan Dalaman kami.
Penafian
Maklumat dan penerbitan adalah tidak dimaksudkan untuk menjadi, dan tidak membentuk, nasihat untuk kewangan, pelaburan, perdagangan dan jenis-jenis lain atau cadangan yang dibekalkan atau disahkan oleh TradingView. Baca dengan lebih lanjut di Terma Penggunaan.