Make iLowest() return the most recent bar shift?

 

Is there any way to make function iLowest() to return the most *recent* bar's shift when analyzing a series of bars, and more than one bar is found with identical low price values?

Currently it seems to be returning the farthest away bar's index instead of the newer one...

Thanks!

 

You could do a 2nd, and maybe subsequent iLowest call, finishing at the bar to the right of the one previously returned by iLowest, then compare it's Low to the Low of the previously returned bar, if it higher use the original value if it's the same then use it.

To explain what I mean . .

1st iLowest is from bar 0 to bar 20, it returns bar 15 as the lowest

2nd iLowest is from bar 0 to bar 14, it returns bar 8 as the lowest, Low[15] and Low[8] are compared, if Low[8] is higher then use bar 15 as the lowest, else use bar 8 or perform an additional iLowest from 0 to 7

Reason: