How to put the start & end date of a backtest into a variable?

Back to topics list To post a new topic, please log in or register
avatar
22
Alexnice 2015.11.30 16:38
 
...so that I can use that to name a csv-file which the EA produces. Is there already a built-in variable for that?
avatar
145
aakcaagac 2015.11.30 16:48 #
 
datetime timeval = TimeLocal();
string filename = "file-" + timeval + ".csv";
...

... This will return a string similar to "file-142414233.csv", where this crippled number shows the seconds since 1st of january 1970 until now. You can modify the datetime value to show more representative things like e.g. "file-20151130123359.csv" if you wish.

avatar
2017
gooly 2015.11.30 17:13 #
 
datetime start=0,end=0;
...
int start() {
   if (start==0) start = TimeCurrent();
   end = TimeCurrent();
}
...
double OnTester() {
   string FrTo = TimeToString(start)+"-"+TimeToString(end); // no seconds: 2015.08.12 08:12
   int fnd = StringReplace(FrTo,":",""); //get rid of :
}

avatar
22
Alexnice 2015.11.30 17:23 #
 
...
avatar
22
Alexnice 2015.11.30 17:28 #
 
gooly:

Thanks, gooly. I guess there is no way to have the end date right from the start because the csv-file is written on the fly (output at each bar) and not at the end of the test?
avatar
2017
gooly 2015.11.30 18:35 #
 
Alexnice:
Thanks, gooly. I guess there is no way to have the end date right from the start because the csv-file is written on the fly (output at each bar) and not at the end of the test?

1) You can enter the dates as parameters of the EA,

2) Write a tmp-file and rename it at the end

avatar
22
Alexnice 2015.11.30 19:21 #
 
Nr.2 works for me, thanks a lot.
Back to topics list  

To add comments, please log in or register