MT4 Coding HELP!!!!

 
MT4 Coding HELP!!!!

Pulling my hair out!!! (what little I have)

Trying to develop a routine that will determine what the top of the next hour is (in back testing).

EXAMPLE:

If a trade exits at 21:03 I want to trigger another trade to be entered at the top of the next hour (22:00).

The normal DateTime functions are of no value because they go by the CURRENT server time and is useless for back testing. Also tried iTime() but didn't have any luck with it as well.


// if there are no current orders active

   if(OrderSelect(0, SELECT_BY_POS)==false)

   {

// this is using the DateTime functions (which I know don't work)

// output of the routine will be a STRING formated as "HH:MM" (i.e. 22:00)

      string a = TimeToStr(iTime(NULL,1,0));

      string b = StringSubstr(a,0,2);

      int c = StrToDouble(b)+1;

      string d = DoubleToStr(c,0);

      string e = d+":00";

      StartTime = StrToTime(e);

     }



Any suggestions would be welcome. Keep in mind this needs to work for BACK TESTING

 
I guess I don't understand your problem:

I compile and run this EA and it comments the time/date as per the current bar on the test, so you can get
"time" from the chart...

int init()
  {
   return(0);
  }

int deinit()
  {
   return(0);
  }

int start()
  {  
   Comment("Bar Number = ", Bars, " Current Bar Time = ", TimeToStr(Time[0], TIME_DATE|TIME_SECONDS),"\n",
   	  "Time Hour of current bar = ", TimeHour(Time[0]), "  TIme Minute = ", TimeMinute(Time[0]));
   return(0);
  }




Reason: