Problem with backtest premature completion

 

The backtests I am running over long periods are apparently not running to the full period specified in the strategy tester input.

I can not think of any reason why this might be occuring. I have tried everything I know. Does anyone know what might be the cause?

I am running backtests on EURUSD M5, disconnected, spread 1.6 pips, on an up to date Alpari demo account.

For example:

If I select from 2006.04.01 - 2012.04.01 in the strategy tester input, then the results in the results window go from 2006.04.05 - 2009.12.09 (228 trades).

If I select from 2008.04.01 - 2012.04.01 in the strategy tester input then the results in the results window go from 2008.04.02 - 2010.11.01 (161 trades). 

If I select from 2009.04.01 - 2012.04.01 in the strategy tester input then the results in the results window go from 2009.04.03 - 2011.08.18 (124 trades). 

If I select from 2006.04.01 - 2011.04.01 in the strategy tester input then the results in the results window go from 2006.04.05 - 2009.12.09 (228 trades). 

If I select from 2007.04.01 - 2011.04.01 in the strategy tester input then the results in the results window go from 2007.04.11 - 2010.05.10 (197 trades).

I'm pretty sure this is not just a limitation on the number of trades which can be shown in the results window, because the total number of trades there is the same as that shown in the report. (And obviously I have run backtests before with many more total trades, and the numbers above are different).

I tested EAs on each of the years from 2006 to 2012 separately, and it works fine in each. The problem only occurs when I run many years in one test. Notice that the end date of some of the test periods above are contained within other periods above with no problems!

There are no error messages in the journal. This is not being caused by a stop out as far as I can tell. There is no stop out message in the results window either. In fact, the last trade is often closed at t/p.

When the test stops I always have enough balance that a stop out should be impossible anyway. (End balance always > £1000, only one trade at a time, stop loss of 100 pips, constant lotsize of 0.1, up to date Alpari demo account).

I also take the stop loss and lotsize into account when opening a new position, so stop outs should never occur.

The data is M1 data downloaded from FXDD and converted to M5 using the default period converter. I wrote a script to check for holes, and there are a few M1 bars missing here and there (at night time and new year), but nothing serious. 

I have tried this on two separate computers. One running Win 7 with MT4 installed on a separate partition. The other running XP with MT4 installed in program files. The same problem occurs on both. I am hoping this is not a problem with my hardware / software.

As far as I can tell I am imposing no artificial limitations on the period which can be tested. I'm pretty sure there are no limiting factors in the code of the EA. Max bars in history and max bars in chart are both set to 10 million.

When I manually check the data I can see that there is never a hole at the place where the backtest stops.

I can see no pattern in the times it chooses to stop. End date, bars tested, trades made and end balance all seem to be fairly random. The green status bar does run the last part of the test very fast though.

Sorry to ask such a noob question! I can't believe I have never noticed this problem before (perhaps because I usually test each year separately).

 
clerin6:

The backtests I am running over long periods are apparently not running to the full period specified in the strategy tester input.

I can not think of any reason why this might be occuring. I have tried everything I know. Does anyone know what might be the cause?

You didn't try using the Searcch in the top right corner of this page or reading a few recent posts . .  there have been at least 2 pots asking the same question in the last week.
 

Thanks. I see them now.

I did do a Google search, and I searched other forums and specifically this forum separately - last weekend.

All I got was a swamp of pages talking about bad history data, stop outs, close at stops, mix ups in internal variables, MT4 installed into program files, bad methods of limiting trades to once per bar, and people actively trying to stop their backtests early.

I guess I was typing in the wrong description for the problem.

After a week of going through them and pulling my hair out I just had to ask the question. Granted, I didn't go back and specifically re-check the last week's worth of questions here.

Now that I know how to phrase the problem, I found a potential fix here if anyone else wants it: https://www.mql5.com/en/forum/124870

I just tested it, and it works.

On the down side it slightly reduces the acuity of backtesting, and I suppose it means any indicators using volume will not work properly. On the up side it means a much longer period can be tested, and the testing speed is significantly improved.

I am guessing that the number of price points interpolated by the backstester for each bar is exactly the same as the value for the volume of that bar. I suppose the realistic minimum you would need then would be a volume of 4 - 20.

Thanks again :-)

 

I dont get it. Ive had this problem for many months now. First of all, I dont understand what the script is supposed to be doing. Is it just shortening the file?

It opens the HST files which are encrypted. I cant see how you expect to open manipulate an encrypted file and then rewrite it and have it work in MT4.

I read the script and It  has this comment     "// loop on all volume values and overwrite them"

HUH? the data is encrypted! Someone please set me straight here. I must be missing something.

 
hkjonus:

I dont get it. Ive had this problem for many months now. First of all, I dont understand what the script is supposed to be doing. Is it just shortening the file?

It opens the HST files which are encrypted. I cant see how you expect to open manipulate an encrypted file and then rewrite it and have it work in MT4.

I read the script and It  has this comment     "// loop on all volume values and overwrite them"

HUH? the data is encrypted! Someone please set me straight here. I must be missing something.

LOL . . . encrypted hst file ?  really ?  why do you say that ?  because you can't open it in Notepad ?  it is a binary file not a txt file . . .  just to be clear . . . the hst files and for that matter the fxt file too are NOT encrypted . . .  if they were how would one manage to create an offline chart ?
Reason: