Erfan jafari
Erfan jafari

Reputation: 13

How to get number of a special bar in pine script

I'm trying to get number of a bar in pine script. For example i want find the highest bar for each 24 bars. And i need the number of that bar not the value. I tried

Highest(high,24)

But it returns value!!!!

Upvotes: 0

Views: 238

Answers (1)

PineCoders-LucF
PineCoders-LucF

Reputation: 8789

See highesbars():

//@version=4
study("")
hi = highest(high,24)
hiIndex = - highestbars(high, 24)
hiBarIndex = bar_index[hiIndex]

plot(hi, "hi")
plot(hiIndex, "hiIndex")
plot(hiBarIndex, "hiBarIndex")

Upvotes: 0

Related Questions