Help get this topic noticed by sharing it on Twitter, Facebook, or email.

Question about Pine Script

I am trying to understand this pine script

study(title="HiLo Activator", overlay=true)
length = input(3, minval=1)
displace = input(0, minval=0)
highsma = sma(high, length)
lowsma = sma(low, length)
swing = iff(close > highsma[displace], 1, iff(close < lowsma[displace], -1, 0))
mah = highest(high, length)
mal = lowest(low, length)
stop = iff(swing==1, mal, iff(swing==-1, mah, stop[1]))
linecolor = iff(stop < low, green, red)
plot(stop, style=line, linewidth=2, color=linecolor)

My problem is with the stop.

I can't understand this:

stop = iff(swing==1, mal, iff(swing==-1, mah, stop[1]))

it is like:

if swing is 1 than stop is mal
else
if swing is -1 than stop is mah
else
stop is stop[1]

what is stop[1] ????????

thanks
1 person has
this question
+1
Reply