I am trying to make a trailingstop multiple of the ATR, since a buy or sell signal has occured. Naturally I try the barssince(long)
function, to determine the amount of bars since the buy signal. Then I use the highest
function to find the highest ATR value since my buy signal. My code is:
atr = atr(input(defval=14, title="ATR"))
Multip = input(0.2, minval = 0)
lower = low - atr * Multip
upper = high + atr * Multip
barssincelong = barssince(long)
barssinceshort = barssince(short)
islong = barssincelong < barssinceshort
plotlower= highest(lower, barssincelong)
plotupper= lowest(upper, barssinceshort)
stoplossline = islong ? plotlower : plotupper
plot(stoplossline)
"long" and "short" are defined in the code above that, but that is irrelevant.
For some odd reason, this script gives a Study Error that says:
"Invalid value of the 'length' argument (0) in the 'highest' function. It must be > 0.
Can someone help me with this problem?
question from:
https://stackoverflow.com/questions/65870422/how-can-i-fix-the-study-error-invalid-value-of-the-length-argument-0-in-th 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…