OPEN-SOURCE SCRIPT

Credit Spread Monitor: HY & IG vs US10Y

72
๐Ÿ“‰ Credit Spread Monitor: HY & IG vs US10Y

This indicator provides a dynamic and visual way to monitor credit spreads relative to the US Treasury benchmark. By comparing High Yield (HY) and Investment Grade (IG) corporate bond yields to the 10-Year US Treasury Yield (US10Y), it helps assess market stress, investor risk appetite, and potential macro turning points.

๐Ÿ” What It Does

-Calculates credit spreads:

HY Spread = BAMLH0A0HYM2EY โˆ’ US10Y
IG Spread = BAMLC0A0CMEY โˆ’ US10Y

-Detects macro risk regimes using statistical thresholds and yield curve signals:

๐Ÿ”ด HY Spread > +2ฯƒ โ†’ Potential financial stress
๐ŸŸ  Inverted Yield Curve + HY Spread > 2% โ†’ Recession risk
๐ŸŸข HY Spread < 1.5% โ†’ Risk-on environment

-Visually highlights conditions with intuitive background colors for fast decision-making.

๐Ÿ“Š Data Sources Explained

๐Ÿ”ด High Yield (HY): BAMLH0A0HYM2EY โ†’ ICE BofA US High Yield Index Effective Yield
๐Ÿ”ต Investment Grade (IG): BAMLC0A0CMEY โ†’ ICE BofA US Corporate Index Effective Yield
โšช Treasury 10Y: US10Y โ†’ 10-Year US Treasury Yield
โšช Treasury 2Y: US02Y โ†’ 2-Year US Treasury Yield (used to detect curve inversion)

โœ… This Indicator Is Ideal For:

Macro traders looking to anticipate economic inflection points
Portfolio managers monitoring systemic risk or credit cycles
Fixed-income analysts tracking the cost of corporate borrowing
ETF/Asset allocators identifying shifts between risk-on and risk-off environments

๐Ÿง  Why It's Useful
This script helps visualize how tight or loose credit conditions are relative to government benchmarks. Since HY spreads typically widen before major downturns, this tool can provide early warning signals. Similarly, compressed spreads may indicate overheating or complacency in risk markets.

๐Ÿ› ๏ธ Practical Use Case:
Youโ€™re managing a multi-asset portfolio. The HY spread jumps above +2ฯƒ while the yield curve remains inverted. You decide to reduce exposure to equities and high-yield bonds and rotate into cash or Treasuries as recession risk rises.

๐Ÿ“Ž Additional Notes
Sourced from FRED (Federal Reserve Economic Data) and TradingViewโ€™s bond feeds.
Designed to work best on daily resolution, using open prices to ensure consistency across series with different update timings.

This script is original, not based on built-in or public templates, and intended to offer educational, statistical, and visual insights for serious market participants.

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.