OPEN-SOURCE SCRIPT

Yield Curve Regimes

60
Overview
The Yield Curve Regime Histogram transforms yield curve spread analysis into an intuitive visual framework by classifying rate movements into six distinct regimes. Rather than simply displaying the spread between two maturities, this indicator analyzes how that spread is changing relative to the underlying yields themselves, providing insight into market expectations for growth, inflation, and liquidity conditions.

How It Works
The indicator calculates the spread between two user-selected government bond yields (default: 2-year and 10-year US Treasuries) and compares both the spread and the individual yields to their values n periods ago (default lookback: 20 bars). Based on whether the spread is steepening or flattening, and whether the short-term and long-term yields are rising or falling, the algorithm classifies each bar into one of six regimes:
The Six Regimes

Steepening Regimes (spread increasing):

1. Bull Steepener (Cyan): Both yields falling, long-end falling slower
  • Market pricing: Growth concerns, but long-end supported
  • Typically risk-on if Fed not cutting due to severe economic weakness

2. Bear Steepener (Blue): Both yields rising, long-end rising faster
  • Market pricing: Growth acceleration, inflation pressures building
  • Typically risk-on regime

3. Steepener Twist (Yellow): Short-end falling, long-end rising
  • Market pricing: Liquidity injection, mixed growth signals
  • Neutral/transition regime

Flattening Regimes (spread decreasing):

4. Bull Flattener (Pink): Both yields falling, long-end falling faster
  • Market pricing: Growth slowdown, disinflation, potential inversion ahead
  • Typically risk-off regime

5. Bear Flattener (Purple): Both yields rising, short-end rising faster
  • Market pricing: Central bank tightening, growth concerns emerging
  • Typically risk-off regime, can lead to inversion

6. Flattener Twist (Orange): Short-end rising, long-end falling
Market pricing: Aggressive policy tightening, recession risk building
Typically risk-off regime, highest inversion risk


Practical Application
By visualizing which regime is active, traders can:

Anticipate risk appetite shifts: Steepening regimes generally coincide with risk-on sentiment, while flattening regimes (especially with falling long-end yields) often precede risk-off periods
Gauge growth and inflation expectations: The combination of spread direction and yield levels reveals what markets are pricing for economic trajectory
Identify liquidity conditions: Twist regimes highlight periods of central bank intervention or significant policy shifts
Time entries and exits: Regime transitions can signal turning points in equity, commodity, and currency markets before they fully materialize in price action


Customization
The indicator offers full flexibility for cross-market analysis:

Maturity selection: Choose any two yield curves (e.g., 2Y/10Y, 5Y/30Y, or international equivalents like German Bunds)
Lookback period: Adjust sensitivity by changing how far back the comparison is made
Color scheme: Customize each regime's color in the Style tab to match your chart preferences
Legend display: Toggle the regime legend table on/off for cleaner visuals
Timeframe: Apply the indicator to any timeframe, from intraday to monthly charts


Display
The spread is plotted as a histogram, with each bar colored according to its regime classification. A black line overlay (also customizable) traces the raw spread value, allowing you to see both the regime structure and the actual spread level simultaneously. An optional legend in the top-right corner provides a quick reference for regime identification.
This indicator is designed to function as a standalone "yield curve dashboard" that can be stacked beneath equity indices, commodities, or FX pairs, helping traders align their positioning with the underlying rates environment without needing to interpret complex macro data manually.



Note: This indicator analyzes government bond yields and is most effective when paired with liquid, benchmark instruments such as US Treasuries, German Bunds, or UK Gilts. Regime classifications reflect market expectations embedded in the yield curve, not guaranteed outcomes.

免責事項

この情報および投稿は、TradingViewが提供または推奨する金融、投資、トレード、その他のアドバイスや推奨を意図するものではなく、それらを構成するものでもありません。詳細は利用規約をご覧ください。