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.
نص برمجي مفتوح المصدر
بروح TradingView الحقيقية، قام مبتكر هذا النص البرمجي بجعله مفتوح المصدر، بحيث يمكن للمتداولين مراجعة وظائفه والتحقق منها. شكرا للمؤلف! بينما يمكنك استخدامه مجانًا، تذكر أن إعادة نشر الكود يخضع لقواعد الموقع الخاصة بنا.
إخلاء المسؤولية
لا يُقصد بالمعلومات والمنشورات أن تكون، أو تشكل، أي نصيحة مالية أو استثمارية أو تجارية أو أنواع أخرى من النصائح أو التوصيات المقدمة أو المعتمدة من TradingView. اقرأ المزيد في شروط الاستخدام.
نص برمجي مفتوح المصدر
بروح TradingView الحقيقية، قام مبتكر هذا النص البرمجي بجعله مفتوح المصدر، بحيث يمكن للمتداولين مراجعة وظائفه والتحقق منها. شكرا للمؤلف! بينما يمكنك استخدامه مجانًا، تذكر أن إعادة نشر الكود يخضع لقواعد الموقع الخاصة بنا.
إخلاء المسؤولية
لا يُقصد بالمعلومات والمنشورات أن تكون، أو تشكل، أي نصيحة مالية أو استثمارية أو تجارية أو أنواع أخرى من النصائح أو التوصيات المقدمة أو المعتمدة من TradingView. اقرأ المزيد في شروط الاستخدام.