Treasury Yield Spread 10y-2y [TXMC]
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// @TXMC

//@version=5
indicator(title="Treasury Yield Spread 10y-2y [TXMC]", overlay=false, precision=2)

// Yield curve
curve = request.security("FRED:T10Y2Y", timeframe.period, close)        // 10yr minus 2yr Treasury yield

// Inversion band color -- if below zero, show color
plotColor = curve < 0 ? color.new(#00a1e4,75) : na

// Plots
plot(curve, color=#133336, style=plot.style_line, linewidth=1, trackprice=true, title="10y-2y")
bgcolor(plotColor)
hline(0, linewidth=1, color=#fe4a49, title='Zero')