Download MetaTrader 5

Strategy-Tester Start-Date - can I get it?

To add comments, please log in or register
Carl Schreiber
Carl Schreiber 2015.02.22 20:10 

Is there a way to get the start date of the fxt-tester-file?

If I start a backtest I see in the journal: 

2015.02.22 21:02:00.775 TestGenerator: symbol EURUSD period 1 model 0 from 2011.11.06 to 2015.02.06

Is there a way to check in OnInit() whether the start-date of the EA (Time[0]) is too close to the "Use-Date From:.." in the case I need to set some indicators and values by prior bars?

ffoorr 2015.02.23 13:43  

Tester start at the same date than indicated in the tester, unless  there is indication style:  if( Bars < 500 ) return(0); in an indicator or in an EA.

othewise the tester start with 1000 Bars, 

Just code some object LABEL whitch show those indications

whroeder1 2015.02.23 13:58  
Build 599- guaranteed that there will be at least 100 bars from the initial bar zero. If you need more, you must check for that and handle it - tester irrelevant.
Carl Schreiber
Carl Schreiber 2015.02.23 15:46  

As I created the fxt-files myself and set them write-protect your a.m. suggestions will not work in my case I guess.

But I see in the journal-tab the fist and last date so I had a little hope to get these values inside an EA.

Of course I can find a way with the hard coded begin-date - but I'd like to avoid this.

ffoorr 2015.02.23 19:52  

Look at that whroeder, it's a back test in M1, start date in tester is 3 February

I have this line in the EA but it do not matter :

void OnTick()
   if(Bars < 550 ) return(0);
Carl Schreiber
Carl Schreiber 2015.02.23 22:00  

For a multi-time frame EA I use only m1. From there I 'fill' the needed amount of bars to start trading.

Now I wanted to have a test whether the highest timeframe (e.g. D1) still has enough m1 bars before the trading starts:

e.g. I nee 100 bars => 100*1440 => 144000 minute bars.

Due to the weekends (no bars but lots of seconds) I can't just calculate Time[0]-144000*60 :(

I found this solution

datetime tmeStart = iTime(NULL,PERIOD_M1, iBarShift(NULL,PERIOD_M1,iTime(NULL,PERIOD_D1,100)));
if ( tmeStart == 0 ) return( INIT_PARAMETERS_INCORRECT ); 

If now this tmeStart is before the first date of the data I get 0.

For real-time chart this is not required!

To add comments, please log in or register