Backtesting.

 
Hi. Does anyone of you know a way to test EA on M1? I would like the test to be performed only at the times I specify.

For example. The EA is to start at 4 p.m. and end after making the set profit or close all open positions at 8 p.m.

Thank you in advance for your tips.
 
tymek86:
Hi. Does anyone of you know a way to test EA on M1? I would like the test to be performed only at the times I specify.

For example. The EA is to start at 4 p.m. and end after making the set profit or close all open positions at 8 p.m.

Thank you in advance for your tips.

I don't think strategy tester offers that option. But you can create a time filter inside your EA code.

 
Yashar Seyyedin #:

I don't think strategy tester offers that option. But you can create a time filter inside your EA code.

Thank you, I have added a time filter in my EA. It works on a demo and real account, but I can't test it retrospectively. After setting the properties in the tester, the time still works according to the date and not the designated hours.
 
tymek86 #:
Thank you, I have added a time filter in my EA. It works on a demo and real account, but I can't test it retrospectively. After setting the properties in the tester, the time still works according to the date and not the designated hours.

you may limited time for specific day not all days.

   datetime day0 = iTime(Symbol(), PERIOD_D1, 0);
   MqlDateTime mytime;
   TimeToStruct(day0, mytime);
   mytime.hour = 0; mytime.min=0; mytime.sec=0;
   day0 = StructToTime(mytime);
   
   datetime Stime = 16 * 3600 + 0 * 60;///Means 04:00 PM
   datetime Etime = 20 * 3600 + 0 * 60;// Means 08:00 PM
   
   if (TimeCurrent()<day0 + Stime || TimeCurrent()>day0 + Etime) return;

did not checked it but it has to work. add this code to OnTick function as very first line.

- you can make 16:00 and 20:00 as an input for EA

- Also consider if you have any Trailing or Breakeven in your code, those most probably have to be before this code.

Reason: