OPEN-SOURCE SCRIPT
Spreads CCC/BBB/AAA vs Treasury 10Y

//version=5
indicator("Spreads CCC/BBB/AAA vs Treasury 10Y", overlay=false)
// Tickes de ejemplo (debes reemplazar con los que tengas disponibles en TradingView)
ccc = request.security("XCCC", "D", close) // High Yield CCC
bbb = request.security("LQD", "D", close) // Investment Grade BBB
aaa = request.security("QLTA", "D", close) // AAA
treasury = request.security("US10Y", "D", close) // US Treasury 10Y
// Cálculo del spread (yield bono - yield Treasury)
spread_ccc = ccc - treasury
spread_bbb = bbb - treasury
spread_aaa = aaa - treasury
// Umbral para alerta de riesgo
umbral = input.float(2.0, "Umbral spread (%)")
// Plot de los spreads
plot(spread_ccc, color=color.red, title="Spread CCC")
plot(spread_bbb, color=color.orange, title="Spread BBB")
plot(spread_aaa, color=color.green, title="Spread AAA")
// Señal visual cuando el spread supera el umbral
plotshape(spread_ccc > umbral, title="Alerta CCC", color=color.red, style=shape.triangledown, location=location.abovebar, size=size.tiny)
plotshape(spread_bbb > umbral, title="Alerta BBB", color=color.orange, style=shape.triangledown, location=location.abovebar, size=size.tiny)
plotshape(spread_aaa > umbral, title="Alerta AAA", color=color.green, style=shape.triangledown, location=location.abovebar, size=size.tiny)
indicator("Spreads CCC/BBB/AAA vs Treasury 10Y", overlay=false)
// Tickes de ejemplo (debes reemplazar con los que tengas disponibles en TradingView)
ccc = request.security("XCCC", "D", close) // High Yield CCC
bbb = request.security("LQD", "D", close) // Investment Grade BBB
aaa = request.security("QLTA", "D", close) // AAA
treasury = request.security("US10Y", "D", close) // US Treasury 10Y
// Cálculo del spread (yield bono - yield Treasury)
spread_ccc = ccc - treasury
spread_bbb = bbb - treasury
spread_aaa = aaa - treasury
// Umbral para alerta de riesgo
umbral = input.float(2.0, "Umbral spread (%)")
// Plot de los spreads
plot(spread_ccc, color=color.red, title="Spread CCC")
plot(spread_bbb, color=color.orange, title="Spread BBB")
plot(spread_aaa, color=color.green, title="Spread AAA")
// Señal visual cuando el spread supera el umbral
plotshape(spread_ccc > umbral, title="Alerta CCC", color=color.red, style=shape.triangledown, location=location.abovebar, size=size.tiny)
plotshape(spread_bbb > umbral, title="Alerta BBB", color=color.orange, style=shape.triangledown, location=location.abovebar, size=size.tiny)
plotshape(spread_aaa > umbral, title="Alerta AAA", color=color.green, style=shape.triangledown, location=location.abovebar, size=size.tiny)
Open-source script
In true TradingView spirit, the creator of this script has made it open-source, so that traders can review and verify its functionality. Kudos to the author! While you can use it for free, remember that republishing the code is subject to our House Rules.
Disclaimer
The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.
Open-source script
In true TradingView spirit, the creator of this script has made it open-source, so that traders can review and verify its functionality. Kudos to the author! While you can use it for free, remember that republishing the code is subject to our House Rules.
Disclaimer
The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.