Get the recent high in the range

consider this line HHVBars(H, 10). This will fetch the periods that have passed since H reached its peak first time in the last 10 bars. see chart below

I have tried

BarIndex()-ValueWhen(H==HHV(H, 10), BarIndex())

But it fails When the period parameter is an array.
What is the fool proof way of calculating the required i.e bars since the recent peak in the range.

HHVBars gives exactly that (the number of bars since last highest high).

A NEW high counts.

If you want price that hits OLD high to be counted, you can add small delta to high prices to artificially make same high a little bit higher.

delta = Cum( 0.0001 ); // monotonically increasing value
bars = HHVBars( H + delta, 1 ); // if you do this OLD high will count as new

see this chart

I recommend re-reading my answer instead of jumping with replies.
You need to slow down.

sorry we posted at the same time. Your post was not added at the time i hit reply.
Thankyou Tomasz. I will try this. :pray:

Only a Beautiful Mind can think of such a solution.

This topic was automatically closed 100 days after the last reply. New replies are no longer allowed.