2
votes

I am using MQL4.

Currently, I am using [Expert Advisor]-s in MT4.StrategyTester, and set a period-of-time by the build-in pull-down calendar GUI-elements.

What I want to do is to setup a period-of-time straight in an MQL4-source code.

If it is realized, for example, I can compare the result

'from 2011/01-to 2011/12' 

to

'from 2012/01-to 2012/12'

and so on.

1

1 Answers

1
votes

There is an easy solution to the requirement, even with an added value for a fully automated, large-scale hyper-parameter optimisations inside the said MT4.StrategyTester tool, using the proposed pair of parameters ( aStartFromDATE and aRunTillDATE ) as an iterable tuple, that could be harnessed into a TradingStrategy robustness cross-validations of its release-candidates over some sweeping/sliding calendar window-of-time.

extern datetime aStartFromDATE = D'2010.01.01 00:00';
extern datetime   aRunTillDATE = D'2345.01.01 00:00';

void OnTick(){
     if (  Time < aStartFromDATE
        || Time >   aRunTillDATE
           ){
           IgnoreTicksOutsideTheGivenPeriodOfTime();
           return;
     }
  // SURE TO BE INSIDE THE GIVEN ( MT4.STRATEGY/TESTER ITERABLE ) PERIOD OF TIME
     ...
     ..
     .
}
void IgnoreTicksOutsideTheGivenPeriodOfTime(){
  // Ignore, but still may do execute some utility service during a void run
}

Be careful on different scopes of syntax support:

One might be also cautious on use-cases, that include StrategyTester restrictions for some of the powerful new-syntax-constructors:

A PrintFormat() being one of such un-supported pieces inside the StrategyTester during hyper-parameter optimisations.

PrintFormat() function does not work during optimization in the Strategy Tester.