Indicator · Pine Script v4 · Own pane

US Treasury Yields

by everget

This indicator plots US Treasury yield closes from external symbols in a separate pane.

View on GitHub

Repaints

GitHub stars948on the repository
Pine versionv4older, still runs
Lines of code94
Settings4inputs
LicenceGPL-3.0
Last update10 days ago18 Oct 2026

Add It to Your TradingView Chart

  1. 1Copy the scriptPress Copy script above, or the copy button on the code below.
  2. 2Open the Pine EditorOpen a TradingView chart and choose Pine Editor at the bottom of the screen.
  3. 3Paste over the templateCreate a new indicator, select all of the template text and paste. Press Save and give it a name.
  4. 4Add it to the chartPress Add to chart, then adjust the settings with the gear icon next to its name.

Source Code

94 lines of Pine Script v4 from statistics/us_treasury_yields.pine, published under GPL-3.0. Keep the author's credit and licence lines when you reuse it.

us_treasury_yields.pine
//@version=4
// Copyright (c) 2020-present, Alex Orekhov (everget)
// US Treasury Yields script may be freely distributed under the terms of GPL-3.0 license.
study("US Treasury Yields", format=format.price)

mode = input(title="Display Mode", defval="Columns", options=["Lines", "Columns"])
lineWidth = input(title="Lines Width", type=input.integer, defval=2)
columnWidth = input(title="Columns Width", type=input.integer, defval=12)
space = input(title="Space Between Columns", type=input.integer, defval=8)

//------------------------------------------------------------------------------

_get(sym) =>
    out = nz(security(sym, timeframe.period, close, barmerge.gaps_off, barmerge.lookahead_on))
    out

//------------------------------------------------------------------------------

modeLines = mode == "Lines"

labelColor = #1e90ff
textColor = color.white

US30Y = _get("TVC:US30Y")

plot(not modeLines ? US30Y : na, title="30Y, %", offset=(0 * space), color=#f1625e, style=plot.style_histogram, linewidth=columnWidth, show_last=1, editable=false)
plot(modeLines ? US30Y : na, title="30Y, %", color=#f1625e, linewidth=lineWidth, editable=false)
plotshape(not modeLines ? min(US30Y, 0) : na, offset=(0 * space), title="US30Y", text=" 30Y ", color=labelColor, textcolor=textColor, style=shape.labelup, location=location.absolute, size=size.small, show_last=1, transp=0, editable=false)

US10Y = _get("TVC:US10Y")

plot(not modeLines ? US10Y : na, title="10Y, %", offset=(-1 * space), color=#9ace73, style=plot.style_histogram, linewidth=columnWidth, show_last=1, editable=false)
plot(modeLines ? US10Y : na, title="10Y, %", color=#9ace73, linewidth=lineWidth, editable=false)
plotshape(not modeLines ? min(US10Y, 0) : na, offset=(-1 * space), title="US10Y", text=" 10Y ", color=labelColor, textcolor=textColor, style=shape.labelup, location=location.absolute, size=size.small, show_last=1, transp=0, editable=false)

US07Y = _get("TVC:US07Y")

plot(not modeLines ? US07Y : na, title="7Y, %", offset=(-2 * space), color=#ffdf82, style=plot.style_histogram, linewidth=columnWidth, show_last=1, editable=false)
plot(modeLines ? US07Y : na, title="7Y, %", color=#ffdf82, linewidth=lineWidth, editable=false)
plotshape(not modeLines ? min(US07Y, 0) : na, offset=(-2 * space), title="US07Y", text=" 7Y ", color=labelColor, textcolor=textColor, style=shape.labelup, location=location.absolute, size=size.small, show_last=1, transp=0, editable=false)

US05Y = _get("TVC:US05Y")

plot(not modeLines ? US05Y : na, title="5Y, %", offset=(-3 * space), color=#bb8954, style=plot.style_histogram, linewidth=columnWidth, show_last=1, editable=false)
plot(modeLines ? US05Y : na, title="5Y, %", color=#bb8954, linewidth=lineWidth, editable=false)
plotshape(not modeLines ? min(US05Y, 0) : na, offset=(-3 * space), title="US05Y", text=" 5Y ", color=labelColor, textcolor=textColor, style=shape.labelup, location=location.absolute, size=size.small, show_last=1, transp=0, editable=false)

US03Y = _get("TVC:US03Y")

plot(not modeLines ? US03Y : na, title="3Y, %", offset=(-4 * space), color=#4363d8, style=plot.style_histogram, linewidth=columnWidth, show_last=1, editable=false)
plot(modeLines ? US03Y : na, title="3Y, %", color=#4363d8, linewidth=lineWidth, editable=false)
plotshape(not modeLines ? min(US03Y, 0) : na, offset=(-4 * space), title="US03Y", text=" 3Y ", color=labelColor, textcolor=textColor, style=shape.labelup, location=location.absolute, size=size.small, show_last=1, transp=0, editable=false)

US02Y = _get("TVC:US02Y")

plot(not modeLines ? US02Y : na, title="2Y, %", offset=(-5 * space), color=#c46c54, style=plot.style_histogram, linewidth=columnWidth, show_last=1, editable=false)
plot(modeLines ? US02Y : na, title="2Y, %", color=#c46c54, linewidth=lineWidth, editable=false)
plotshape(not modeLines ? min(US02Y, 0) : na, offset=(-5 * space), title="US02Y", text=" 2Y ", color=labelColor, textcolor=textColor, style=shape.labelup, location=location.absolute, size=size.small, show_last=1, transp=0, editable=false)

US01Y = _get("TVC:US01Y")

plot(not modeLines ? US01Y : na, title="1Y, %", offset=(-6 * space), color=#5ec27c, style=plot.style_histogram, linewidth=columnWidth, show_last=1, editable=false)
plot(modeLines ? US01Y : na, title="1Y, %", color=#5ec27c, linewidth=lineWidth, editable=false)
plotshape(not modeLines ? min(US01Y, 0) : na, offset=(-6 * space), title="US01Y", text=" 1Y ", color=labelColor, textcolor=textColor, style=shape.labelup, location=location.absolute, size=size.small, show_last=1, transp=0, editable=false)

US06MY = _get("TVC:US06MY")

plot(not modeLines ? US06MY : na, title="6M, %", offset=(-7 * space), color=#e6194b, style=plot.style_histogram, linewidth=columnWidth, show_last=1, editable=false)
plot(modeLines ? US06MY : na, title="6M, %", color=#e6194b, linewidth=lineWidth, editable=false)
plotshape(not modeLines ? min(US06MY, 0) : na, offset=(-7 * space), title="US06MY", text=" 6M ", color=labelColor, textcolor=textColor, style=shape.labelup, location=location.absolute, size=size.small, show_last=1, transp=0, editable=false)

US03MY = _get("TVC:US03MY")

plot(not modeLines ? US03MY : na, title="3M, %", offset=(-8 * space), color=#3cb44b, style=plot.style_histogram, linewidth=columnWidth, show_last=1, editable=false)
plot(modeLines ? US03MY : na, title="3M, %", color=#3cb44b, linewidth=lineWidth, editable=false)
plotshape(not modeLines ? min(US03MY, 0) : na, offset=(-8 * space), title="US03MY", text=" 3M ", color=labelColor, textcolor=textColor, style=shape.labelup, location=location.absolute, size=size.small, show_last=1, transp=0, editable=false)

US02MY = _get("TVC:US02MY")

plot(not modeLines ? US02MY : na, title="2M, %", offset=(-9 * space), color=#ffe119, style=plot.style_histogram, linewidth=columnWidth, show_last=1, editable=false)
plot(modeLines ? US02MY : na, title="2M, %", color=#ffe119, linewidth=lineWidth, editable=false)
plotshape(not modeLines ? min(US02MY, 0) : na, offset=(-9 * space), title="US02MY", text=" 2M ", color=labelColor, textcolor=textColor, style=shape.labelup, location=location.absolute, size=size.small, show_last=1, transp=0, editable=false)

US01MY = _get("TVC:US01MY")

plot(not modeLines ? US01MY : na, title="1M, %", offset=(-10 * space), color=#f58231, style=plot.style_histogram, linewidth=columnWidth, show_last=1, editable=false)
plot(modeLines ? US01MY : na, title="1M, %", color=#f58231, linewidth=lineWidth, editable=false)
plotshape(not modeLines ? min(US01MY, 0) : na, offset=(-10 * space), title="US01MY", text=" 1M ", color=labelColor, textcolor=textColor, style=shape.labelup, location=location.absolute, size=size.small, show_last=1, transp=0, editable=false)

levelLabelColor = #f9ce02
levelColor = #674ea7

plot(0.0, title="", style=plot.style_circles, linewidth=0, color=levelLabelColor, editable=false)
hline(0.0, title="Zero Level", linestyle=hline.style_dotted, color=levelColor)

Overview

US Treasury Yields shows the 30-year, 10-year, 7-year, 5-year, and 3-year yields as continuous lines or as single-bar histogram columns with short labels. Display mode switches between lines and columns, and the remaining inputs set line width, column width, and the space between columns. It does not generate trade signals. Yields are requested with lookahead enabled.

Details

Published by

everget on GitHub

Type

Indicator, Pine Script v4

Draws

Separate pane below the chart

Category

Screeners & dashboards

Markets

Any symbol

Timeframes

Any timeframe

Risk Notes

  • Signals can change on the live bar or after it closes (repainting)
  • Reads higher-timeframe data with lookahead on, so the history can show signals that were not there in real time

Topics

pinepinescripttechnical-indicatorsindicatorsoscillatorbandsaveragetradingviewindicatormoving-average

Settings

The inputs you can change from the gear icon on the chart. Defaults are the author's.

SettingTypeDefaultVariable
Display ModestringColumnsmode
Lines Widthint2lineWidth
Columns Widthint12columnWidth
Space Between Columnsint8space
Third-party code. ForexR did not write, test or endorse this script, and the summary above was generated automatically from its code and README. Indicators describe the past, and a strategy's backtest can look better than live trading, especially when a script repaints. Check it in the Strategy Tester and on a demo account before you rely on it.

Similar Pine Scripts

This indicator scans a pasted list of symbols for RSI directional momentum and shows matching long and short signals in a table in a separate pane. The user chooses continuous break, continuous retracement, flip break, flip retracement, divergence, or hidden d

Indicator v6 Oscillators & momentumDivergence
Updated 1 year ago · MPL-2.0 GitHub repository of Momentum Setup - RSI Directional Momentum Scanner

Tables-001

by ricardosantos79
261 stars

This indicator builds a TradingView table in a separate pane and fills its cells with fixed placeholder text according to whether each row and column index is even or odd. Users set the table position, the number of rows and columns, and the background, frame,

Indicator v4 Screeners & dashboards
Updated 4 years ago · None stated GitHub repository of Tables-001
257 stars

Donald SPX - Options Trading is an indicator designed to assist SPX index option traders by tracking session benchmarks and multi-timeframe moving average data. It calculates a 200-period weighted moving average (WMA) and requests multi-timeframe bar data from

Indicator v5 Moving averagesScreeners & dashboards Repaints
Updated 6 weeks ago · None stated GitHub repository of Donald SPX - Options Trading

Index Member Distribution

by TradersPost
218 stars

Calculates and plots a weighted histogram of constituent returns for major market indices (NDX, SPX, DJIA, and RUT) in a separate pane. Each histogram bin reflects the summed weights of members within that percentage return bracket. The script renders vertical

Indicator v6 Screeners & dashboards
Updated 3 months ago · None stated GitHub repository of Index Member Distribution

KamaFama

by Mastaaa1987
141 stars

KamaFama is an indicator that translates a Freqtrade trading strategy into Pine Script for visualization. It combines Kaufman Adaptive Moving Average (KAMA), MAMA/FAMA calculations derived via Hilbert Transform, Williams %R, and correlation trend filters to ev

Indicator v6 Moving averagesOscillators & momentum
Updated 6 weeks ago · MIT GitHub repository of KamaFama
114 stars

Calculates normalized reversal metrics across up to ten Forex currency pairs using user-selected moving average methods, including HarmonicMA, EMA, SMA, or WMA. The indicator identifies overbought, oversold, and mean-crossing conditions using a configurable th

Indicator v4 Screeners & dashboardsMean reversion
Updated 1 year ago · None stated GitHub repository of Multi-Pair Trend Reversal Widget

More indicators

Trade Your Charts With a Regulated Broker

Compare brokers that connect to TradingView, with spreads, minimum deposits and leverage side by side.

Compare brokers