Sma 9/50/180 | ema 20 | buy/sell

Found this on Tradeview and wanted to see if it could be converted to Tradovate. The original Author posted its as Open Source script here is the code if anyone thinks it will work.

SMA 9/50/180 | EMA 20 | BUY/SELL

study(title=“SMA 9/50/180 | EMA 20 | BUY/SELL”, overlay=true)

//SMA and EMA code
smaInput1 = input(9, title=“SMA1”)
smaInput2 = input(50, title=“SMA2”)
smaInput3 = input(180, title=“SMA3”)
emaInput1 = input(20, title=“EMA1”)
sma1 = sma(close, smaInput1)
sma2 = sma(close, smaInput2)
sma3 = sma(close, smaInput3)
EMA1 = ema(close, emaInput1)
plot(sma1, color= color.red , title=“SMA1”)
plot(sma2, color = color.blue, title=“SMA2”)
plot(sma3, color= color.white, title=“SMA3”)
plot(EMA1, color = color.yellow, title=“EMA1”)

//@version=4
no=input(3,title=“BUY/SELL Swing”)
Barcolor=input(false,title=“BUY/SELL Bar Color”)
Bgcolor=input(false,title=“BUY/SELL Background Color”)
res=highest(high,no)
sup=lowest(low,no)
avd=iff(close>res[1],1,iff(close<sup[1],-1,0))
avn=valuewhen(avd!=0,avd,0)
tsl=iff(avn==1,sup,res)
Buy=crossover(close,tsl)
Sell=crossunder(close,tsl)
plotshape(Buy,title=“Buy”, color=color.green, style=shape.arrowup,location=location.belowbar, text=“Buy”)
plotshape(Sell,title=“Sell”, color=color.red, style=shape.arrowdown,text=“Sell”)
colr = close>=tsl ? color.green : close<=tsl ? color.red : na
plot(tsl, color=colr, linewidth=3, title=“BUY/SELL Chart Line”)
barcolor(Barcolor ? colr : na)
bgcolor(Bgcolor ? colr :na)
alertcondition(Buy, title=“Buy Signal”, message=“Buy”)
alertcondition(Sell, title=“Sell Signal”, message=“Sell”)