SSL Indicator

Hello,
Is it possible to code the SSL Indicator, I have it converted to TOS from Trading View. Many thanks!

#also gannhilow
#https://www.tradingview.com/script/xzIoaIJC-SSL-channel/
declare upper;
input period=8;
input avgType=averageType.simple;
def avgHigh=movingAverage(avgType,high, period);
def avgLow=movingAverage(avgType,low, period);;

def H1v = if isnan(close[1]) then 0
else if close > avghigh then 1
else if close<avgLow then -1
else H1v[1];

plot sslDown= if h1v<0 then avghigh else avglow;
ssldown.setDefaultColor(color.red);
plot sslUp= if h1v<0 then avgLow else avghigh;
sslUP.setDefaultColor(color.green);
addcloud(sslup,ssldown,color.dark_green,color.red);