Abz Bond returns
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © Abzorba
// It is inspired by the technical analysis of @GameOfTrades on Twitter

//@version=5
indicator("Abz US10y bond returns", shorttitle="Abz Bond returns", overlay=false, timeframe="", timeframe_gaps=false, explicit_plot_zorder=true)

bonds = request.security("US10Y","D",close)
col1 = bonds > bonds[1]
col2 = bonds < bonds[1]
color1 = col1 ? #21AA00 : col2 ? #960012 : color.gray
bondline = plot(bonds, color = color1,linewidth=2, title = "Bond returns")

malen = input.int(50, "Longest MA Length", minval=1)
maTA = ta.ema(bonds, malen)
col3 = bonds > maTA
col4 = bonds < maTA
color3 = col1 ? #21AA00 : col2 ? #960012 : color.gray
maplot = plot(maTA, color = #611000)
fill(bondline,maplot, color=color.new(color3, 90))