Strategy Tester - set custom start time

 

is is possible to set the start time for the strategy tester?

it's always starting at 00:00 when there is rather little movement.

I tried searching google and mt4/mt5 forum but no clue.

I adjusted my system time/time-zone but without any effect.

thanks in advance

 
ranxero:

is is possible to set the start time for the strategy tester?

As far as I know you cannot set a start time for the strategy tester itself.

The start time must be coded into the EA that you are testing.

 

Keith Watford

thank you for the reply. do you have any clue how this can be achieved?

 
ranxero:

Keith Watford

thank you for the reply. do you have any clue how this can be achieved?

Yes, but I have no time at the moment. There should be plenty of examples in the codebase or even from a search in the forum.

 
Hi, do you have any indicator/EA programing experience?
 

Bostock58

yes, I have ... some :)

 
//--- input parameters
input int      StartHour=3;
input int      StartMinute=33;
input int      EndHour=18;
input int      EndMinute=18;
//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()
  {
//---
   startTime=StartHour*60+StartMinute;
   stopTime=EndHour*60+EndMinute;
//---
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick()
  {
   if(!timeToTrade && IsTimeToTrade())
     {
      Print(TimeToString(TimeCurrent()));
      timeToTrade=true;
     }
   if(timeToTrade && !IsTimeToTrade())
     {
      Print(TimeToString(TimeCurrent()));
      timeToTrade=false;
     }
//---
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
MqlDateTime dt;
datetime time,prevTime;
int startTime,stopTime,minutes;
bool timeToTrade=false;
//---
bool IsTimeToTrade()
  {
   if((time=iTime(_Symbol,PERIOD_M1,0))!=prevTime)
     {
      TimeToStruct(time,dt);
      minutes=dt.hour*60+dt.min;
      prevTime=time;
     }
//---
   if(startTime<stopTime)
      return(minutes>=startTime && minutes<stopTime);
   else   
      return(minutes>=startTime || minutes>=startTime?minutes>stopTime:minutes<stopTime);
  }
//+------------------------------------------------------------------+
 

Ernst Van Der Merwe

thanks a lot for the code.

but as far as I understand it, this will "just" detect whether the tester has reached a certain time period.

I guess I wasn't clear enough in my question:

I have the issue, that when I start the tester it's always starting at 00:00 so I have to let it run for ~ 8 hours until the

time period I'm interested in comes up.

your code will still leave me with this issue.

but still, I figured, with the slider in the tester settings I can push time forward and your code will

help avoid making trades at unwanted times.

so this is definitely an approach - *THANKS* :)


still, it would be nice to have some settig for the tester to define the start time as well as the date.

if anyone knows about such a feature, please get back to me.

 

If you can limit your EA to the trading times you want and the strategy tester will run a months price action in about 3 seconds, I am struggling with why the 8 hour at the beginning of the 'month' has any relevance...?

Is this JUST lack of control with the slider?