OPEN-SOURCE SCRIPT
Yield Curve Monitor

What you see in the preview image
The chart displays the complete US Treasury yield curve as a smooth log-scaled polyline drawn to the right of the last bar, with all eleven maturities from 1-month T-bills to 30-year bonds plotted at their actual yield values. The solid line shows today's curve; the dashed line shows the curve from 21 trading days ago for direct visual comparison. Each tenor is labeled with its name and yield in percent. To the right, a comprehensive dashboard table lists every maturity with current yield, the change in basis points versus the historical reference date, and a relative magnitude bar. Below the maturity rows the four most-watched yield-curve spreads are shown (2s10s, 3m10y, 2s30s, 5s30s) with their current value, change versus history, and inversion status. The footer classifies both the current and historical curves into one of five regimes — Steep, Normal, Flat, Inverted, or Humped — using a user-selectable slope metric.
What this indicator does
This is a complete US Treasury yield-curve workstation built into a single TradingView pane. It solves a problem that ordinary time-series indicators cannot: the yield curve is fundamentally a cross-sectional object — yield as a function of maturity at a single moment — but standard charts plot variables against time. By rendering the curve as a polyline anchored to the right of the last bar, with maturity on a logarithmic x-axis and yield on the price axis, the indicator gives you a real, geometrically faithful view of curve shape, alongside a complete data table and historical comparison.
Eleven maturities are pulled from TradingView's TVC feed at daily resolution: US01MY, US03MY, US06MY, US01Y, US02Y, US03Y, US05Y, US07Y, US10Y, US20Y, US30Y. Each tenor is requested twice — once for the current bar and once for a user-defined lookback offset — giving the indicator a paired snapshot that drives every visualization and metric. If a specific tenor is unavailable on your data plan (US20Y is the most common gap), that point silently drops from the curve and shows an em dash in the table — no errors are raised.
Settings explained
Display group
Curves geplottet (Curves to plot) — choose which yield curves are drawn to the right of the last bar: , , or . The dashboard table always shows both datasets regardless of this setting; this toggle controls only the visual polyline. The tenor labels next to the points always reflect the curve being plotted (or the current curve when both are shown).Current onlyHistoric onlyBoth
Slope-Metrik (Shape-Klassifikation) — selects which spread drives the Steep / Normal / Flat / Inverted / Humped classification shown in the dashboard footer. Six options are available: (the default, broadest possible measure), (classic NBER recession lead-indicator), (the Federal Reserve's preferred recession signal), (long-end steepness), (pure long-end term-premium proxy), and (full-spectrum slope excluding T-bills). Each metric has its own empirically calibrated thresholds (see the Methodology section), so the classification remains meaningful regardless of which spread you choose. Alerts also fire on the selected spread.30y - 3m10y - 2y (2s10s)10y - 3m (3m10y)30y - 5y (5s30s)30y - 10y (10s30s)30y - 2y (2s30s)
Dashboard anzeigen — show or hide the data table.
Tabellen-Position — five anchor points for the dashboard: top-left, top-right, middle-right, bottom-right, bottom-left.
Historic Lookback (Daily Bars) — the number of trading days back used for the historical comparison. Default is 21, which approximates one trading month. Useful presets: 21 ≈ 1 month, 63 ≈ 1 quarter, 126 ≈ 6 months, 252 ≈ 1 year. Maximum 504 bars (≈ 2 years).
Style group
Five customizable colors mapped to semantic roles (Bull/Steep/Current, Bear/Inversion, Neutral/Normal, Warning/Flat/Hump, Historic). One additional input controls the polyline line width (1 to 5). All defaults match a dark theme; the colors can be repointed to fit any chart style.
Alerts group
Two alert toggles: one fires when the user-selected slope metric crosses below zero (inversion event), the other when it crosses back above zero (re-steepening event). Both alerts trigger on confirmed daily-bar closes only — there is no intrabar repainting.
What the dashboard shows
The table is divided into three blocks.
Maturity block (eleven rows) — one row per tenor showing the current yield to three decimal places, the change in basis points versus the lookback date with directional color (green up, red down), and a magnitude bar built from filled and empty Unicode block characters that visualizes the yield's size relative to the highest yield in the curve. This block lets you read absolute levels and recent moves at a glance.
Key Spreads block (four rows) — the four most-watched curve spreads (2s10s, 3m10y, 2s30s, 5s30s), each with current value, change in basis points versus the lookback date, and an OK / INVERTED status flag. These four are shown unconditionally regardless of which slope metric you selected for shape classification, so you always have the full institutional toolkit visible.
Curve Shape block (one or two rows) — one row per plotted curve (Current and/or Historic, depending on the curve toggle). Each row shows the regime label (STEEP, NORMAL, FLAT, INVERTED, or HUMPED) on a colored background matching the regime, the current slope value of the selected metric, and the metric's name. This lets you compare regime states between today and the lookback date directly: the curve may have shifted from FLAT to STEEP, for example, even if both versions are visible on the chart.
Methodology — shape classification
The indicator uses the user-selected spread as its primary slope input, with four absolute thresholds calibrated empirically from US Treasury data since 1990:
30y - 3m Steep : +1.5% Normal > +0.3% Flat > -0.3% Inverted ≤ -0.3%
10y - 2y (2s10s) +1.0% +0.2% -0.2% -0.2%
10y - 3m (3m10y) +1.5% +0.3% -0.3% -0.3%
30y - 5y (5s30s) +0.7% +0.15% -0.15% -0.15%
30y - 10y (10s30s) +0.5% +0.1% -0.1% -0.1%
30y - 2y (2s30s) +1.0% +0.2% -0.2% -0.2%
The thresholds reflect each spread's historical distribution: the long-end spreads (5s30s, 10s30s) have far narrower ranges than the broad measures (30y-3m, 3m10y), so applying a single global threshold would over-classify the long-end as STEEP at almost every reading. By calibrating per metric, the classification stays meaningful no matter which spread the user selects.
A separate Hump detection runs alongside: if the maximum yield in the curve falls in the belly (2Y, 3Y, 5Y, or 7Y) and the overall slope is below twice the Normal threshold, the curve is classified as HUMPED. This identifies the canonical inverted-belly shape that often signals a near-term policy-rate peak followed by expected easing.
How to read the curve
A Steep curve typically associates with early-cycle expansions, accommodative monetary policy, or rising inflation expectations — investors demand higher compensation to lend further out. A Normal curve is the long-term default state of healthy bond markets. A Flat curve indicates near-equality of short and long expectations, typically near cyclical turning points. An Inverted curve, where long yields trade below short yields, has preceded every US recession since the 1960s with an average lead time of roughly 12 to 18 months — this is the signal to watch for. A Humped shape, where the belly trades above both ends, typically reflects market pricing of a near-term hiking cycle followed by expected cuts.
The dashed historical curve makes regime transitions visually obvious. If the solid current curve sits below the dashed reference across all tenors, yields have fallen broadly (a bond rally). If the curves cross — for example, the short end is up but the long end is down — the curve has flattened or inverted further during the lookback window. If the spread between them widens at the long end, term premium is expanding.
Repainting and data behavior
All calls use . Alerts trigger only on confirmed daily-bar closes. There is no repainting on confirmed bars.request.securitylookahead = barmerge.lookahead_off
When the chart is on an intraday timeframe, the displayed yields reflect the most recent closed daily bar — during the US trading session this means yesterday's settlement until the new daily close prints. This is correct, non-repainting behavior and is consistent with how all daily-resolution data is served on TradingView.
The pane scales automatically to the yield range using two invisible anchor plots (min and max across both current and historical curves). This ensures the polyline always uses the full vertical space without manual axis adjustment, regardless of the absolute level of yields.
Limitations
The classification thresholds are static absolutes, not adaptive. In persistent low-rate regimes (such as 2010-2021) the STEEP threshold may register slightly too generously; in high-rate regimes the FLAT threshold may understate compression. The numerical slope value is always shown alongside the label, so you can apply your own judgment when the regime label feels off.
The Hump detection uses a simple argmax check on the belly tenors rather than a full curvature metric (such as the 2 × 5Y minus 2Y minus 10Y butterfly). It is most reliable when the selected slope metric spans the full curve (30y-3m, 3m10y, 2s10s); for narrow long-end metrics (5s30s, 10s30s) the belly lies outside the metric's span and Hump classification can be misleading. When in doubt, switch the slope metric to for the most robust shape reading.30y - 3m
Only US Treasuries are supported in this version. The architecture leaves headroom in the request.security budget (22 of 40 calls used) for adding additional sovereign curves (Bunds, Gilts, JGBs) in future updates.
Two alert conditions are exposed for the user-selected slope metric:
Selected Spread Inversion — fires when the chosen spread crosses below zero (e.g., from positive to negative 2s10s). Useful as an early-warning trigger in macro frameworks.
Selected Spread Re-Steepening — fires when the chosen spread crosses back above zero. The bull-versus-bear-steepener distinction (which end of the curve is moving) requires looking at the individual yields in the dashboard at the moment the alert fires.
Alerts respect the user's slope-metric selection — switching from 2s10s to 3m10y in the settings will redirect the alerts to the new spread automatically.
Recommended use
Place the indicator on a daily chart of a broad US equity index (SPX, ES1!, SPY) to visualize how historical yield-curve regimes have aligned with equity-market phases — the inversion shading and shape labels make prior recession signals immediately visible. For fixed-income traders, place it directly on a Treasury futures chart (ZN1!, ZB1!) to use the live curve view as a directional input alongside the underlying price action. For macro discretionary traders, the configurable slope metric lets you align the shape classification with whichever spread your framework prioritizes — Fed-watchers typically use 3m10y, recession-modelers use 2s10s, term-premium analysts use 5s30s or 10s30s.
Originality
This indicator combines three distinct visualizations of the same dataset — a cross-sectional polyline curve drawn to the right of the last bar, a comprehensive numerical dashboard with eleven tenors and four spreads, and a configurable shape classification with per-metric calibrated thresholds — into a single, self-contained workspace. The log-scaled cross-sectional curve drawing using Pine v6's polyline objects, the historical comparison overlay, and the user-selectable slope metric with empirically calibrated thresholds per spread are not, to my knowledge, available in this combination in other public yield-curve scripts on the platform.
The chart displays the complete US Treasury yield curve as a smooth log-scaled polyline drawn to the right of the last bar, with all eleven maturities from 1-month T-bills to 30-year bonds plotted at their actual yield values. The solid line shows today's curve; the dashed line shows the curve from 21 trading days ago for direct visual comparison. Each tenor is labeled with its name and yield in percent. To the right, a comprehensive dashboard table lists every maturity with current yield, the change in basis points versus the historical reference date, and a relative magnitude bar. Below the maturity rows the four most-watched yield-curve spreads are shown (2s10s, 3m10y, 2s30s, 5s30s) with their current value, change versus history, and inversion status. The footer classifies both the current and historical curves into one of five regimes — Steep, Normal, Flat, Inverted, or Humped — using a user-selectable slope metric.
What this indicator does
This is a complete US Treasury yield-curve workstation built into a single TradingView pane. It solves a problem that ordinary time-series indicators cannot: the yield curve is fundamentally a cross-sectional object — yield as a function of maturity at a single moment — but standard charts plot variables against time. By rendering the curve as a polyline anchored to the right of the last bar, with maturity on a logarithmic x-axis and yield on the price axis, the indicator gives you a real, geometrically faithful view of curve shape, alongside a complete data table and historical comparison.
Eleven maturities are pulled from TradingView's TVC feed at daily resolution: US01MY, US03MY, US06MY, US01Y, US02Y, US03Y, US05Y, US07Y, US10Y, US20Y, US30Y. Each tenor is requested twice — once for the current bar and once for a user-defined lookback offset — giving the indicator a paired snapshot that drives every visualization and metric. If a specific tenor is unavailable on your data plan (US20Y is the most common gap), that point silently drops from the curve and shows an em dash in the table — no errors are raised.
Settings explained
Display group
Curves geplottet (Curves to plot) — choose which yield curves are drawn to the right of the last bar: , , or . The dashboard table always shows both datasets regardless of this setting; this toggle controls only the visual polyline. The tenor labels next to the points always reflect the curve being plotted (or the current curve when both are shown).Current onlyHistoric onlyBoth
Slope-Metrik (Shape-Klassifikation) — selects which spread drives the Steep / Normal / Flat / Inverted / Humped classification shown in the dashboard footer. Six options are available: (the default, broadest possible measure), (classic NBER recession lead-indicator), (the Federal Reserve's preferred recession signal), (long-end steepness), (pure long-end term-premium proxy), and (full-spectrum slope excluding T-bills). Each metric has its own empirically calibrated thresholds (see the Methodology section), so the classification remains meaningful regardless of which spread you choose. Alerts also fire on the selected spread.30y - 3m10y - 2y (2s10s)10y - 3m (3m10y)30y - 5y (5s30s)30y - 10y (10s30s)30y - 2y (2s30s)
Dashboard anzeigen — show or hide the data table.
Tabellen-Position — five anchor points for the dashboard: top-left, top-right, middle-right, bottom-right, bottom-left.
Historic Lookback (Daily Bars) — the number of trading days back used for the historical comparison. Default is 21, which approximates one trading month. Useful presets: 21 ≈ 1 month, 63 ≈ 1 quarter, 126 ≈ 6 months, 252 ≈ 1 year. Maximum 504 bars (≈ 2 years).
Style group
Five customizable colors mapped to semantic roles (Bull/Steep/Current, Bear/Inversion, Neutral/Normal, Warning/Flat/Hump, Historic). One additional input controls the polyline line width (1 to 5). All defaults match a dark theme; the colors can be repointed to fit any chart style.
Alerts group
Two alert toggles: one fires when the user-selected slope metric crosses below zero (inversion event), the other when it crosses back above zero (re-steepening event). Both alerts trigger on confirmed daily-bar closes only — there is no intrabar repainting.
What the dashboard shows
The table is divided into three blocks.
Maturity block (eleven rows) — one row per tenor showing the current yield to three decimal places, the change in basis points versus the lookback date with directional color (green up, red down), and a magnitude bar built from filled and empty Unicode block characters that visualizes the yield's size relative to the highest yield in the curve. This block lets you read absolute levels and recent moves at a glance.
Key Spreads block (four rows) — the four most-watched curve spreads (2s10s, 3m10y, 2s30s, 5s30s), each with current value, change in basis points versus the lookback date, and an OK / INVERTED status flag. These four are shown unconditionally regardless of which slope metric you selected for shape classification, so you always have the full institutional toolkit visible.
Curve Shape block (one or two rows) — one row per plotted curve (Current and/or Historic, depending on the curve toggle). Each row shows the regime label (STEEP, NORMAL, FLAT, INVERTED, or HUMPED) on a colored background matching the regime, the current slope value of the selected metric, and the metric's name. This lets you compare regime states between today and the lookback date directly: the curve may have shifted from FLAT to STEEP, for example, even if both versions are visible on the chart.
Methodology — shape classification
The indicator uses the user-selected spread as its primary slope input, with four absolute thresholds calibrated empirically from US Treasury data since 1990:
30y - 3m Steep : +1.5% Normal > +0.3% Flat > -0.3% Inverted ≤ -0.3%
10y - 2y (2s10s) +1.0% +0.2% -0.2% -0.2%
10y - 3m (3m10y) +1.5% +0.3% -0.3% -0.3%
30y - 5y (5s30s) +0.7% +0.15% -0.15% -0.15%
30y - 10y (10s30s) +0.5% +0.1% -0.1% -0.1%
30y - 2y (2s30s) +1.0% +0.2% -0.2% -0.2%
The thresholds reflect each spread's historical distribution: the long-end spreads (5s30s, 10s30s) have far narrower ranges than the broad measures (30y-3m, 3m10y), so applying a single global threshold would over-classify the long-end as STEEP at almost every reading. By calibrating per metric, the classification stays meaningful no matter which spread the user selects.
A separate Hump detection runs alongside: if the maximum yield in the curve falls in the belly (2Y, 3Y, 5Y, or 7Y) and the overall slope is below twice the Normal threshold, the curve is classified as HUMPED. This identifies the canonical inverted-belly shape that often signals a near-term policy-rate peak followed by expected easing.
How to read the curve
A Steep curve typically associates with early-cycle expansions, accommodative monetary policy, or rising inflation expectations — investors demand higher compensation to lend further out. A Normal curve is the long-term default state of healthy bond markets. A Flat curve indicates near-equality of short and long expectations, typically near cyclical turning points. An Inverted curve, where long yields trade below short yields, has preceded every US recession since the 1960s with an average lead time of roughly 12 to 18 months — this is the signal to watch for. A Humped shape, where the belly trades above both ends, typically reflects market pricing of a near-term hiking cycle followed by expected cuts.
The dashed historical curve makes regime transitions visually obvious. If the solid current curve sits below the dashed reference across all tenors, yields have fallen broadly (a bond rally). If the curves cross — for example, the short end is up but the long end is down — the curve has flattened or inverted further during the lookback window. If the spread between them widens at the long end, term premium is expanding.
Repainting and data behavior
All calls use . Alerts trigger only on confirmed daily-bar closes. There is no repainting on confirmed bars.request.securitylookahead = barmerge.lookahead_off
When the chart is on an intraday timeframe, the displayed yields reflect the most recent closed daily bar — during the US trading session this means yesterday's settlement until the new daily close prints. This is correct, non-repainting behavior and is consistent with how all daily-resolution data is served on TradingView.
The pane scales automatically to the yield range using two invisible anchor plots (min and max across both current and historical curves). This ensures the polyline always uses the full vertical space without manual axis adjustment, regardless of the absolute level of yields.
Limitations
The classification thresholds are static absolutes, not adaptive. In persistent low-rate regimes (such as 2010-2021) the STEEP threshold may register slightly too generously; in high-rate regimes the FLAT threshold may understate compression. The numerical slope value is always shown alongside the label, so you can apply your own judgment when the regime label feels off.
The Hump detection uses a simple argmax check on the belly tenors rather than a full curvature metric (such as the 2 × 5Y minus 2Y minus 10Y butterfly). It is most reliable when the selected slope metric spans the full curve (30y-3m, 3m10y, 2s10s); for narrow long-end metrics (5s30s, 10s30s) the belly lies outside the metric's span and Hump classification can be misleading. When in doubt, switch the slope metric to for the most robust shape reading.30y - 3m
Only US Treasuries are supported in this version. The architecture leaves headroom in the request.security budget (22 of 40 calls used) for adding additional sovereign curves (Bunds, Gilts, JGBs) in future updates.
Two alert conditions are exposed for the user-selected slope metric:
Selected Spread Inversion — fires when the chosen spread crosses below zero (e.g., from positive to negative 2s10s). Useful as an early-warning trigger in macro frameworks.
Selected Spread Re-Steepening — fires when the chosen spread crosses back above zero. The bull-versus-bear-steepener distinction (which end of the curve is moving) requires looking at the individual yields in the dashboard at the moment the alert fires.
Alerts respect the user's slope-metric selection — switching from 2s10s to 3m10y in the settings will redirect the alerts to the new spread automatically.
Recommended use
Place the indicator on a daily chart of a broad US equity index (SPX, ES1!, SPY) to visualize how historical yield-curve regimes have aligned with equity-market phases — the inversion shading and shape labels make prior recession signals immediately visible. For fixed-income traders, place it directly on a Treasury futures chart (ZN1!, ZB1!) to use the live curve view as a directional input alongside the underlying price action. For macro discretionary traders, the configurable slope metric lets you align the shape classification with whichever spread your framework prioritizes — Fed-watchers typically use 3m10y, recession-modelers use 2s10s, term-premium analysts use 5s30s or 10s30s.
Originality
This indicator combines three distinct visualizations of the same dataset — a cross-sectional polyline curve drawn to the right of the last bar, a comprehensive numerical dashboard with eleven tenors and four spreads, and a configurable shape classification with per-metric calibrated thresholds — into a single, self-contained workspace. The log-scaled cross-sectional curve drawing using Pine v6's polyline objects, the historical comparison overlay, and the user-selectable slope metric with empirically calibrated thresholds per spread are not, to my knowledge, available in this combination in other public yield-curve scripts on the platform.
オープンソーススクリプト
TradingViewの精神に則り、このスクリプトの作者はコードをオープンソースとして公開してくれました。トレーダーが内容を確認・検証できるようにという配慮です。作者に拍手を送りましょう!無料で利用できますが、コードの再公開はハウスルールに従う必要があります。
免責事項
これらの情報および投稿は、TradingViewが提供または承認する金融、投資、取引、またはその他の種類の助言もしくは推奨であることを意図したものではなく、またこれらに該当するものでもありません。詳細は利用規約をご覧ください。
オープンソーススクリプト
TradingViewの精神に則り、このスクリプトの作者はコードをオープンソースとして公開してくれました。トレーダーが内容を確認・検証できるようにという配慮です。作者に拍手を送りましょう!無料で利用できますが、コードの再公開はハウスルールに従う必要があります。
免責事項
これらの情報および投稿は、TradingViewが提供または承認する金融、投資、取引、またはその他の種類の助言もしくは推奨であることを意図したものではなく、またこれらに該当するものでもありません。詳細は利用規約をご覧ください。