Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
my first algo, TTM Squeeze Code and some questions followed

Hi, guys,

I use TTM Squeeze in tradingview before, so I wrote a similar one in case anyone needs this.
I have some following questions:

in author's origin code, I only implemented squeeze on and squeeze off , I wonder how can I
implement the code below? Many thanks

val = linreg(source - avg(avg(highest(high, lengthKC), lowest(low, lengthKC)),sma(close,lengthKC)),
lengthKC,0)

bcolor = iff( val > 0,
iff( val > nz(val[1]), lime, green),
iff( val < nz(val[1]), red, maroon))
scolor = noSqz ? blue : sqzOn ? black : gray
plot(val, color=bcolor, style=histogram, linewidth=4)
plot(0, color=scolor, style=cross, linewidth=2)