Optimize EA over a time window

 

Is it possible to make the Strategy Tester to Optimize EA running it automatically multiple times over a range of time windows?

So, instead of picking a static Start and End dates, I want to make the End date = Today, but the Start date to start from 2024.01.01 run my EA backtest and then re-run the same EA backtest, this time starting from 2024.01.02. Since Dates are not visible in the list of optimizable variables with Start/Step/End, how the above can be acheived?

Any help is highly appreciated! 

 
#property script_show_inputs

input int inAddDays = 2;

#include <fxsaber\MultiTester\MTTester.mqh> // https://www.mql5.com/ru/code/26132

#define _CS(A) ((!IsStopped()) && (A))
#define PAUSE 200

void Run( const string Settings = NULL )
{
  while (_CS(!MTTESTER::IsReady()))
    Sleep(PAUSE);

  MTTESTER::CloseNotChart();
    
  if (_CS((Settings == NULL) || MTTESTER::SetSettings(Settings)))
    MTTESTER::ClickStart(false);

  while (_CS(!MTTESTER::IsReady()))
    Sleep(PAUSE);
}

#define DAY (24 * 3600)

void OnStart()
{
  Run(); // First
  
  for (int i = 0; _CS(i < inAddDays); i++)
  {
    string Settings;
    
    if (MTTESTER::GetSettings(Settings))
    {      
      const datetime FromDate = (datetime)MTTESTER::GetValue(Settings, "FromDate");      
      MTTESTER::SetValue(Settings, "FromDate", TimeToString(FromDate + DAY, TIME_DATE));            

      Run(Settings); // Next
    }
  }
}
 
fxsaber #:

Thank you for the script. Could you please give some hints on how to implement this to address the subject issue? 

 
Maker #:

Thank you for the script. Could you please give some hints on how to implement this to address the subject issue? 

Enable DLL and run this script in terminal, then you will see what will happen with the tester.

 

Hello. I'm getting some errors when compiling. If you could fix them, that would be great!

Automatic translation was applied by a moderator. On the English forum, please write in English.

Files:
1.jpg  96 kb
 
Дмитрий #:

Hello. I'm getting some errors when compiling. If you could fix them, that would be great!

Automatic translation was applied by a moderator. On the English forum, please write in English.

https://www.mql5.com/ru/forum/1111/page3678#comment_58610041