2

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.

user3666197
  • 1
  • 6
  • 50
  • 92
whitebear
  • 11,200
  • 24
  • 114
  • 237

1 Answers1

1

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.

halfer
  • 19,824
  • 17
  • 99
  • 186
user3666197
  • 1
  • 6
  • 50
  • 92
  • Thank you very much!! It's a great hint to set datetime as extern. It works for now. However how can I sweep the periods and optimize? In the 'expert properties' aStartFromDATE and aRunTillDATE are not selectable. I want to set 2012/04/01-2012/04/31,2012/05/01-2012/05-31,2012/06/01-2012/06/30,,,, and so on to see the results by every periods. And thank you for your warning for WIld World of MQL4. I am so thrilled. – whitebear Nov 11 '16 at 08:54
  • Thanks, I put the Anser button , but unable to click up-arrow, it is because of my reputation is too short. Sorry I might be too newbie for stackoverflow. However Even I click the optimisation , selections doesn't become active [img](http://imgur.com/eJxHmik). In the case if I want to sweep calender by months. What do I need to do more?? – whitebear Nov 11 '16 at 11:32
  • I foudn out the way to set the data in source code. Make array for time data set. `datetime StartFromDate[0] = D'2345.01.01 00:00'; datetime StartFromDate[1] = D'2345.02.01 00:00'; datetime StartFromDate[2] = D'2345.03.01 00:00';` then I can use time like this `StartFromDate[i]` and change i variable in optimizasion property. – whitebear Nov 11 '16 at 11:41