iHighest and iLowest

 
datetime openTodayTime=iTime(Symbol(),PERIOD_D1,0); 
datetime openYesterdayTime=iTime(Symbol(),PERIOD_D1,1); 

int openTodayBar=iBarShift(Symbol(),PERIOD_M15,openTodayTime);
int openYesterdayBar=iBarShift(Symbol(),PERIOD_M15,openYesterdayTime);

Print("openTodayBar=",openTodayBar);
Print("openYesterdayBar=",openYesterdayBar);

int highestClose=iHighest(Symbol(),PERIOD_M15,MODE_CLOSE,openYesterdayBar,openTodayBar);
int lowestClose=iLowest(Symbol(),PERIOD_M15,MODE_CLOSE,openYesterdayBar,openTodayBar);

Print("highestClose=",highestClose);
Print("lowesttClose=",lowestClose);

Sometimes the above code returns a bar outside the searched bars.

openYesterdayBar=145 and openTodayBar=76

then

lowestClose=197

How can it return a bar higher than 145?

 

Just looked at the documentation,

//--- From index 4 to index 23 inclusive, on the current timeframe
   int val_index=iHighest(NULL,0,MODE_CLOSE,20,4);

So it searches from bar 4 for 20 bars.

Not between bar 4 and bar 20.
Reason: