High and Low for a given time period

 

I am trying to create an EA that will get the highs and lows for a given time period, i.e.; 00:00 - 03:00. Searching through the forums, I have come up with the following code, but it doesn't work. It prints out 0 instead for the price for the highs and lows. I also get this warning when compiling the EA; '02:00' - date literal string is incomplete.

Any thoughts on how I can get HH and LL reflect the high and low for the given time period?

int Start = iBarShift( NULL, 0, D'00:00',false);
int End = iBarShift( NULL, 0, D'03:00',false);
int Range = Start - End + 1;
int HH = iHighest( NULL, 0, MODE_HIGH, Range, End );

int LL = iLowest( NULL, 0, MODE_LOW, Range, End );


Thanks!

Jerry

 
int Start = iBarShift( NULL, 0, D'00:00',false);

This returns the first bar of the day you compiled the code.

try

for (int End=1;       TimeHour(End)   != 3; End++){}
for (int Start=End+1; TimeHour(Start) != 0; Start++){}
...
or
datetime now  = Time[0],
         sod  = now - now % 86400, // Start of day
         three= sod + 3 * 3600;
if (three > now){ three -= 86400; sod -= 86400; }
int Start = iBarShift(NULL, 0, sod),
    End   = iBarShift(NULL, 0, three); ...
 

Why not:


sod  = iTime(NULL, PERIOD_D1, 0); // Start of day
 
Would work as well, just requires mt4 to load another chart in the background, get the history, get the value. Mine just a divide and subtract instruction.
Reason: