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
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.