Hi, I've seen that systematically the metatrader function iBarShift returns the wrong values in the backtester.
Here you see my code:
previousday_start = iTime(NULL,PERIOD_D1,i);
previousday_end = previousday_start + 24*60*60 -1;
Print ("yesterday start = ", TimeToStr(previousday_start,TIME_DATE|TIME_SECONDS));
Print ("yesterday end = ", TimeToStr(previousday_end ,TIME_DATE|TIME_SECONDS));
start_bar = iBarShift(NULL,PERIOD_M1,previousday_start);
end_bar = iBarShift(NULL,PERIOD_M1,previousday_end);
Print ("start-bar - end-bar = ", start_bar-end_bar);
Print ("start_bar = ", start_bar);
Print ("end_bar = ", end_bar);
When I run this program on the M1 timeframe in the backtester I should expect 1440 as the result of "start_bar-end_bar";
Testing over a long period I never reach 1440 bars (the number of M1 bars in a day).
The maximum result it returns is 1380 instead of 1440
Is this a problem with the function "iBarShift" or is it a problem with Tickstory ?
Does somebody discouvered the same issues ?
Regards,
Danny
iBarShift problems
Re: iBarShift problems
Hi Danny_pip, Are you able to see the minutes that are missing by looking at your debug statements?
Re: iBarShift problems
Hi,
I've added a log-list showing the systematic error with iBarShift.
I've changed the color of the record in the list where the problem arises.
You will see that one hour is skipped when I go minute per minute back in time over 1440 minutes (= 1 day).
The backtester is doing this systematically and never shows 1440 minutes in a day. 1 hour is dissapeared !!!!!!
I've also tested this with version 1.7 and the problem remains the same.
Here's the code I've written to show the problem;
previousday_start = iTime(NULL,PERIOD_D1,i);
previousday_end = previousday_start + 24*60*60 -60;
start_bar = iBarShift(NULL,PERIOD_M1,previousday_start);
end_bar = iBarShift(NULL,PERIOD_M1,previousday_end);
// ***** ONLY FOR TEST *****
datetime testtime;
int currentbar=0;
int end = end_bar+1440;
Log("end_bar = " + end_bar + "start_bar = " + start_bar);
for (i= end_bar; i< end; i++)
{
testtime = iTime(NULL, PERIOD_M1, i);
currentbar = iBarShift(NULL,PERIOD_M1,testtime);
Log( "i = " + i + " Time = " + TimeToStr(testtime,TIME_DATE|TIME_SECONDS) + " BarNr = " + currentbar);
}
Log ("end of cycle");
// ***** ONLY FOR TEST TILL HERE *****
I've added a log-list showing the systematic error with iBarShift.
I've changed the color of the record in the list where the problem arises.
You will see that one hour is skipped when I go minute per minute back in time over 1440 minutes (= 1 day).
The backtester is doing this systematically and never shows 1440 minutes in a day. 1 hour is dissapeared !!!!!!
I've also tested this with version 1.7 and the problem remains the same.
Here's the code I've written to show the problem;
previousday_start = iTime(NULL,PERIOD_D1,i);
previousday_end = previousday_start + 24*60*60 -60;
start_bar = iBarShift(NULL,PERIOD_M1,previousday_start);
end_bar = iBarShift(NULL,PERIOD_M1,previousday_end);
// ***** ONLY FOR TEST *****
datetime testtime;
int currentbar=0;
int end = end_bar+1440;
Log("end_bar = " + end_bar + "start_bar = " + start_bar);
for (i= end_bar; i< end; i++)
{
testtime = iTime(NULL, PERIOD_M1, i);
currentbar = iBarShift(NULL,PERIOD_M1,testtime);
Log( "i = " + i + " Time = " + TimeToStr(testtime,TIME_DATE|TIME_SECONDS) + " BarNr = " + currentbar);
}
Log ("end of cycle");
// ***** ONLY FOR TEST TILL HERE *****
- Attachments
-
[You must be logged in to view this attachment.]
Re: iBarShift problems
Hi Danny,
Can you demonstrate the problem without the use of iBarShift? I'm not sure what the logs indicate, however there appears to be 1440 entries as expected. If there is no data missing from the Tickstory export, it is really something best answered by the MQL forums.
Regards.
Can you demonstrate the problem without the use of iBarShift? I'm not sure what the logs indicate, however there appears to be 1440 entries as expected. If there is no data missing from the Tickstory export, it is really something best answered by the MQL forums.
Regards.