Reputation: 1
I am just starting out on pine scripting and I want to find the bar index of the bar which gave highest volume. Now once I have bar index, would like to use the bar index to find other bar data like low and high of this bar index.
To summarize
bar_index_needed = ta.highest(volume, 10)//though this give volume value not the index value
bar_high_value= func(bar_index_needed , high)
Upvotes: 0
Views: 1204
Reputation: 21121
You can use the ta.barssince()
function to count the number of bars since the last time the condition was true.
//@version=5
indicator("My script", overlay=true)
bar_index_needed = ta.barssince(volume == ta.highest(volume, 10))
_high = high[bar_index_needed]
_low = low[bar_index_needed]
plot(_high, color=color.green, style=plot.style_circles)
plot(_low, color=color.red, style=plot.style_circles)
Upvotes: 1