overnight high and low

 

I want to find the overnight high and low between 2 times but am having some anomalies in the numbers. Is this code correct?
For example, at 0600 we work out out the highs and lows of all candles from 1900 to 0559

It doesn't seem to be counting back to the 1900 candle at present.


double StartHour = 19;
   double EndHour = 6;
   double diff = (EndHour-0)+(24-StartHour);

if(Hour()==EndHour && Minute()==0 && Seconds()==0) 
{
   is_timetocreatependingorders = true;
   double OvernightHigh = High[iHighest(NULL,PERIOD_H1,MODE_HIGH,diff,0)];
   double OvernightLow = Low[iLowest(NULL,PERIOD_H1,MODE_HIGH,diff,0)];  

}

 
SanMiguel:

I want to find the overnight high and low between 2 times but am having some anomalies in the numbers. Is this code correct?
For example, at 0600 we work out out the highs and lows of all candles from 1900 to 0559

It doesn't seem to be counting back to the 1900 candle at present.


double OvernightLow = Low[iLowest(NULL,PERIOD_H1,MODE_HIGH,diff,0)];

Why not

double OvernightLow = Low[iLowest(NULL,PERIOD_H1,MODE_LOW,diff,0)];

 
robofx.org:

Why not

Argh! Yes, thanks :)

Reason: