Reputation: 11
trying to get the value of the previous highest high in pinescript, but this code gives me the previous bar of current highest high.
myper=input(50, "LENGTH")
y1 = highest(high,myper)
yy = valuewhen(high>y1[1],high,0)
plot(yy[1], linewidth=2, color=#00FF00, title="alt")
Can anyone help ?
Upvotes: 1
Views: 3218
Reputation: 3818
Thats because you use the previous value ([1]
) of the yy
series in plot()
function.
//@version=4
study("My Script")
myper=input(50, "LENGTH")
y1 = highest(high,myper)
yy = valuewhen(high>y1[1],high,0)
plot(yy, linewidth=2, color=#00FF00, title="alt")
Upvotes: 1