Relative Strength Comparison
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © imbes

//@version=4
study(title="Relative Strength Comparison", precision=5, shorttitle="RSC")

//Inputs

//compindex=input(type=input.string, title = "Comparison Index", options=["SPY", "SPX", "NDX", "DJI", "IWM", "BTC"], defval="SPY", tooltip="Select the comparison measure")
compindex = input("SPY", type=input.symbol, title = "Enter Comparison Index")

showonlyprice = input(false, title="Show Only Price?", tooltip = "Good for just seeing a different ticker's price at the same time")
usersi=input(type=input.bool, title = "Compare RSI?", defval=false, tooltip="Compare the RSI values instead of price")
showline=input(type=input.bool, title="Show 1.0 line?", defval=false, tooltip="Use this when comparing RSI")
rsilen=input(type=input.integer, title="RSI Length", defval=14, tooltip="Select the length of the RSI lookback")

src=close

//Ticker Info
currentticker = security(syminfo.tickerid, '', close)
comp = security(compindex, '' , close)

currentrsi = security(syminfo.tickerid, '', rsi(src, rsilen))
comprsi = security(compindex, '', rsi(src, rsilen))

//Calcs
defaultr = currentticker / comp
defaultr1 = currentrsi/comprsi
    
hline1=1.0
    
line1=plot(usersi==false and showonlyprice==false ? defaultr : usersi == true and showonlyprice== false ? defaultr1 : usersi==false and showonlyprice==true ? comp : na, title="Ratio Line", color=color.new(color.orange, transp=30), linewidth=1)
line2=plot(usersi==true? hline1 : na, title="1.0 Line", color=color.new(color.white, 70), style=plot.style_line)
    







