OPEN-SOURCE SCRIPT
Yield Curve Regimes

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
2. Bear Steepener (Blue): Both yields rising, long-end rising faster
3. Steepener Twist (Yellow): Short-end falling, long-end rising
Flattening Regimes (spread decreasing):
4. Bull Flattener (Pink): Both yields falling, long-end falling faster
5. Bear Flattener (Purple): Both yields rising, short-end rising faster
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.
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.
오픈 소스 스크립트
트레이딩뷰의 진정한 정신에 따라, 이 스크립트의 작성자는 이를 오픈소스로 공개하여 트레이더들이 기능을 검토하고 검증할 수 있도록 했습니다. 작성자에게 찬사를 보냅니다! 이 코드는 무료로 사용할 수 있지만, 코드를 재게시하는 경우 하우스 룰이 적용된다는 점을 기억하세요.
면책사항
해당 정보와 게시물은 금융, 투자, 트레이딩 또는 기타 유형의 조언이나 권장 사항으로 간주되지 않으며, 트레이딩뷰에서 제공하거나 보증하는 것이 아닙니다. 자세한 내용은 이용 약관을 참조하세요.
오픈 소스 스크립트
트레이딩뷰의 진정한 정신에 따라, 이 스크립트의 작성자는 이를 오픈소스로 공개하여 트레이더들이 기능을 검토하고 검증할 수 있도록 했습니다. 작성자에게 찬사를 보냅니다! 이 코드는 무료로 사용할 수 있지만, 코드를 재게시하는 경우 하우스 룰이 적용된다는 점을 기억하세요.
면책사항
해당 정보와 게시물은 금융, 투자, 트레이딩 또는 기타 유형의 조언이나 권장 사항으로 간주되지 않으며, 트레이딩뷰에서 제공하거나 보증하는 것이 아닙니다. 자세한 내용은 이용 약관을 참조하세요.