Murriex
Murriex

Reputation: 11

How can i get the value of previous highest high in pinescript?

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

Answers (1)

e2e4
e2e4

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")

enter image description here

Upvotes: 1

Related Questions