Diff_US10Y_US02Y
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © easonoic

//@version=5
indicator("Diff_US10Y_US02Y", overlay=true)
US02Y = input.symbol("US02Y", "Symbol")
US10Y = input.symbol("US10Y", "Symbol")

us2y_s_o = request.security(US02Y, 'D', open)
us10y_s_o = request.security(US10Y, 'D', open)
us2y_s_c = request.security(US02Y, 'D', close)
us10y_s_c = request.security(US10Y, 'D', close)
us2y_s_high = request.security(US02Y, 'D', high)
us10y_s_high = request.security(US10Y, 'D', high)
us2y_s_low = request.security(US02Y, 'D', low)
us10y_s_low = request.security(US10Y, 'D', low)

US10Y_US02Y_diff_o = us10y_s_o - us2y_s_o
US10Y_US02Y_diff_c = us10y_s_c - us2y_s_c
US10Y_US02Y_diff_high = us10y_s_high - us2y_s_high
US10Y_US02Y_diff_low = us10y_s_low - us2y_s_low

bool upBar = US10Y_US02Y_diff_c > US10Y_US02Y_diff_o


plotcandle(US10Y_US02Y_diff_o, US10Y_US02Y_diff_high, US10Y_US02Y_diff_low, US10Y_US02Y_diff_c, title='Diff_US10Y_US03Y', color = US10Y_US02Y_diff_o > US10Y_US02Y_diff_c ? color.green : color.red, wickcolor=color.black)
plot(US10Y_US02Y_diff_o, color=color.red, linewidth=2)
plot(0)