Unexpected MT4 Strategy Tester Behaviour

 

I came across this for the first time recently using the MT4 Strategy Tester

USDJPY, 1M, no optimization, "Every Tick" model

Here is the source data that I used to populate the History Centre


open high low  close vol
04.04.2012 03:10:00.000 82.528 82.597 82.520 82.589 242.86
04.04.2012 03:11:00.000 82.590 82.784 82.590 82.784 323.11
04.04.2012 03:12:00.000 82.784 82.861 82.746 82.768 346.27
04.04.2012 03:13:00.000 82.771 82.802 82.728 82.728 285.62
04.04.2012 03:14:00.000 82.728 82.744 82.711 82.721 279.61
04.04.2012 03:15:00.000 82.721 82.799 82.721 82.773 275.92
04.04.2012 03:16:00.000 82.773 82.799 82.763 82.792 198.5
04.04.2012 03:17:00.000 82.789 82.797 82.753 82.760 235.73


And here is the data I logged during the test run (Bid, Ask)

2012-04-04T03:10:01 82.53 82.56
2012-04-04T03:11:01 82.59 82.62
2012-04-04T03:12:01 82.78 82.81
2012-04-04T03:13:01 82.77 82.8
2012-04-04T03:14:01 82.73 82.76
2012-04-04T03:15:01 82.72 82.75
2012-04-04T03:16:01 82.77 82.8
2012-04-04T03:17:01 82.79 82.82




Looks reasonable to me, basically just the open prices with a fixed 3 pip spread. I had the following order open pending prior to the start of this period: PENDING_BUY_STOP, Stop @ 82.69, Take Profit @ 82.77

In 'real' life, this order would have been opened and closed during the bar at (2012-04-04T03:11:01).

However in the simulation, it was opened during the bar at (2012-04-04T03:11:01) and closed during the bar at (2012-04-04T03:12:01). In other words, the closing of this order appears to be a minute later than it should have been.

Here are the corresponding lines from the "results" tab in the Strategy Tester.

1033    2012.04.04 03:12    buy    403    1.00    82.69    0.00    82.77    0.00    73006.37
1034    2012.04.04 03:13    t/p    403    1.00    82.77    0.00    82.77    96.65    73103.02


I understand that we're not modelling tick by tick here, but still, given the M1 data the logical outcome is unambiguous and yet the simulation does not give the same result. Can anyone offer an explanation for this pls?

Thanks

 
cms550790:

I came across this for the first time recently using the MT4 Strategy Tester

USDJPY, 1M, no optimization, "Every Tick" model

Here is the source data that I used to populate the History Centre


open high low  close vol
04.04.2012 03:10:00.000 82.528 82.597 82.520 82.589 242.86
04.04.2012 03:11:00.000 82.590 82.784 82.590 82.784 323.11






Where did your data come from ?  your volume figures are wrong . . .  how do you get 0.86 of a tick ?  I don't think that is the cause of your issue but it raises a question mark over your data . . . 


Your data doesn't tie up with what you have written,  it seems the order was opened at 03:12 not 03:11 and closed at 03:13 not 03:12 

If you are testing this on any other timeframe than M1 then you also need to have the other timeframes derived from the same data otherwise strange things happen.

 
Many thanks for the response. Apologies, yes, I got mixed up somewhat. In fact, I'm questioning my understanding of time date and times noted now. Let me just confirm something first.
I'm reading the data used in the simulation as follows

BID
Time     Open    Close
03:11:01 82.59   82.78
03:12:01 82.78   82.77
03:13:01 82.77   82.73
03:14:01 82.73

The ASK is +3 pips. I've filled in the Close price as I'm assuming that it is taken to be the same as the Open of the next time instant during Simulation, even though the 'raw' data may have a different value. 
Is that reasonable?

1033    2012.04.04 03:12    buy    403    1.00    82.69    0.00    82.77    0.00    73006.37
1034    2012.04.04 03:13    t/p    403    1.00    82.77    0.00    82.77    96.65    73103.02

With regards to the first row here, the time from the first row (2012.04.04 03:12), does this mean "during the minute starting at time 2012.04.04 03:12", ie during the bar (03:12:01 82.78 -> 82.77), 
or does it mean "during the minute ending at time 2012.04.04 03:12", ie during the bar (03:11:01 82.59 -> 82.78)? I think that's where my confusion came from.

In either case it seems an order (PENDING_BUY_STOP, Stop @ 82.69, Take Profit @ 82.77) should be opened and closed at the same time (not sure how to refer to this - either at the same time instant, or 
within the same time period maybe depending on that the times represent). Am I missing something?

The data came from dukascopy some time ago. I'm not clear on what the volume represents to be honest. It's not something I use at present. Does the strategy tester use the volume at all?

At the moment I only use M1 for back testing, derived from a single datafile that I obtained.
 
Many thanks.
 

cms550790:
Many thanks for the response. Apologies, yes, I got mixed up somewhat. In fact, I'm questioning my understanding of time date and times noted now. Let me just confirm something first. 


I'm reading the data used in the simulation as follows

BID
Time     Open    Close
03:11:01 82.59   82.78
03:12:01 82.78   82.77
03:13:01 82.77   82.73
03:14:01 82.73

The ASK is +3 pips. I've filled in the Close price as I'm assuming that it is taken to be the same as the Open of the next time instant during Simulation, even though the 'raw' data may have a different value. 
Is that reasonable?

No,  it is very possible to have a gab between close price and open price of the next bar.
 

cms550790: 

The data came from dukascopy some time ago. I'm not clear on what the volume represents to be honest. It's not something I use at present. Does the strategy tester use the volume at all?
Volume in MT4 is "number of ticks during the bar" . . . noting to do with the amount of the currency that has been traded,  the Strategy Tester uses the volume to determine how many synthetic ticks to make up . . . and place in the fxt file that it uses during the run of the EA in the Tester.

You would be better off using Dukascopy tick data and converting it to M1 using CSV2FXT,  this script will count the number of ticks during each 1 minute time period and use that figure in the M1 hst file it creates.
 

Hi - yep, in fact I did use CSV2FXT to generate that data, however looking back at the datafile I'd used M1 data from dukascopy, not sure if I that was the correct thing to do.

Anyway, I went back to square one, downloaded tick data from dukascopy again QS Tick Data Downloader.

Then i re-ran CSV2FXT which appeared to be successful, HST and FST files generated in history\FXSolutionsUK-Demo Server and \tester\history respectively.

Running the strategy tester initially gave me "22:09:39 TestGenerator: internal error because the file not opened" - seems to be a because the file is readonly from what i've read and tried.

Making it writable then gives me the following:

22:06:29 TestGenerator: invalid file for 'USDJPY1'
22:06:29 jfx: no data for testing

Deleting the FXT file and re-running gives me that same error.

Its trying to write that file, here are the file sizes before (ie as written by CSV2FXT), and after running (with the error).

USDJPY1_0.fxt.backup 35,928KB
USDJPY1_0.fxt 3,880KB

I'm running on Win7 and I know there can be permission type problems if installed in Program Files - so I've also removed from there and am running from a different drive now. I've also set the ownership of the files to me. Given its writing something I don't think this is related to permission, seems to be related to data.

Actually, switching to M5 gives me lots of unmatched data error type error messages but then it does run, so its not permission related.

It seems it still maybe something to do with the data quality. Here are the first and last 5 lines from the 6 month datafile generated by QS Tick Data Downloader.

2012.01.02 00:00:01.370,77.031,77.041,1.88,1.13
2012.01.02 00:00:01.874,77.031,77.041,1.88,1.13
2012.01.02 00:00:05.182,77.033,77.041,1.13,1.13
2012.01.02 00:00:48.046,77.038,77.046,1.50,1.13
2012.01.02 00:00:48.116,77.056,77.076,1.50,2.59

2012.06.01 20:59:53.981,77.991,78.018,0.75,0.75
2012.06.01 20:59:55.150,77.991,78.019,0.75,0.75
2012.06.01 20:59:55.216,77.988,78.019,1.50,0.75
2012.06.01 20:59:59.742,77.986,78.019,0.75,0.75
2012.06.01 21:00:00.134,77.987,78.043,0.75,0.75

I'm a little stumped. I have an 32-bit XP machine I can try to see if I get different results, otherwise I'm not sure what else to try. Do you have any suggestions?

Thank you.

 
cms550790:

Hi - yep, in fact I did use CSV2FXT to generate that data, however looking back at the datafile I'd used M1 data from dukascopy, not sure if I that was the correct thing to do.

Anyway, I went back to square one, downloaded tick data from dukascopy again QS Tick Data Downloader.

Then i re-ran CSV2FXT which appeared to be successful, HST and FST files generated in history\FXSolutionsUK-Demo Server and \tester\history respectively.

You can't use the fxt file unless you buy 3rd party software . . .  you can however use the M1 to MN1 data and let the ST create it's own fxt file from the M1 data

You need to make sure that your Broker doesn't overwrite your Dukascopy data or you will get unmatched data errors . . . you should get none with the Dukascopy data itself as everything,  M1 to MN1 is derived from exactly the same source . . the tick data.

Try this:

  • click login on MT4 and enter a few random numbers for the Login ID, click login,  the login fails and you are now disconnected form your Broker
  • shut down MT4
  • copy your existing USDJPY hst files if you need them for backup purposes
  • copy the CSV2FXT created hst files into your MT4 history folder
  • start MT4, DO NOT login . . .
  • run the Strategy Tester, it will create it's own fxt file based on your new hst files which were created from the tick data . . . you should have zero mismatched data errors 

Reason: