Earnings Yield Spread
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © All_Verklempt

//@version=5
indicator("Earnings Yield Spread", overlay = false)

// earnings yield caluclation
EPS = request.financial(syminfo.tickerid, "EARNINGS_PER_SHARE", "TTM")
EarningsYield = (EPS / close) * 100

// us10y & spread calculation
US10Y = request.security("US10Y", timeframe.period, close)
Spread = EarningsYield - US10Y

// plotting
plot(Spread, "Spread", color = color.blue, linewidth = 3, editable = true)
hline(0,"Zero Line", color = color.gray, linestyle = hline.style_dashed, linewidth = 1)