Strategy Tester Results Chart has problems when using custom data...

 

Hi,

I've created a custom EURUSD-M5 dataset which I've imported into MetaTrader 5 and want to use with the Strategy Tester.

The data set loads fine into Metatrader without any problems or errors. The strategy Tester works fine with this data during the trading simulation processing stage. However, when the final results are presented, the resultant chart that comes up (normally showing where the trades took place etc) has all the trade graphics misaligned with the chart's quote bars. See below:

Chart with trade data misaligned with the bars


It makes no difference which Expert is run (the above results were produced by the MetaTrader provided 'ExpertMACD') - it happens every time. Also, if any of the Experts are run on the standard broker provided data, these problems don't arise. So the problem appears to have something to do with using the Custom Data feature of MetaTrader 5, together with the Strategy Tester. 

The procedure I used to load this custom data is as follows:

  • I pull up the Symbols window (View->Symbols)
  • Under 'Specification', I select EURUSD from the 'Forex' group and click on 'Create Custom Symbol'. I changed the name of the new Symbol to 'EURUSDTest' and left all other EURUSD settings at their defaults.
  • The new Symbol has now been created under the "Custom-Forex" group in the left window.
  • I select the new Symbol ('EURUSDTest') and click on the "Bars" tab
  • Under the "Bars" tab, I click on "Import Bars"
  • I select the file, tick "Tick Volumes" and leave the rest of the settings at their defaults.
  • I press "Ok" and the data loads without any errors.

I've attached the EURUSD-M5 data file to this problem report. If you have any further questions, please don't hesitate to contact me.



Files:
EURUSD-M5.csv  12831 kb
 
So you were able to create your own symbol and assign data to it. Have you made sure that your own symbol ("EURUSDTest") was also used during the backtest? Or could it be that the backtest was done using the regular EURUSD currency pair?
 
WindmillMQL:
So you were able to create your own symbol and assign data to it. Have you made sure that your own symbol ("EURUSDTest") was also used during the backtest? Or could it be that the backtest was done using the regular EURUSD currency pair?

Hi,

Thanks for your reply. And  yes, it was definitely my own Symbol ("EURUSDTest") that was used with the Strategy Tester. In fact, you can even see this in the above graphic (top line of text).

 
cowil:

Hi,

Thanks for your reply. And  yes, it was definitely my own Symbol ("EURUSDTest") that was used with the Strategy Tester. In fact, you can even see this in the above graphic (top line of text).

Okay. The next step would be to go to the journal tab of the backtester and verify the actual fill prices of some of the trades. Are these fill prices in line with your EURUSDTest prices, or is there a large gap? The chart seems to indicate that there is a large gap.
 
WindmillMQL:
Okay. The next step would be to go to the journal tab of the backtester and verify the actual fill prices of some of the trades. Are these fill prices in line with your EURUSDTest prices, or is there a large gap? The chart seems to indicate that there is a large gap.

Hi,

Thanks again for your response. And yes, you're right - the same order fill prices shown with the graphics can also be found in the Journal tab log. So it seems that for whatever reason, the Strategy Tester is massively increasing the fill prices.

I initially thought this may have something to do with a potentially super-inflating spread bug or some such but if this were the case, I would have thought that only the Buy order fill prices would have increased.

I also randomly checked the prices of numerous bars in the chart graphic with the prices in the original quote file - they all definitely match up.

Any other ideas? I'm at a bit of a loss as to where to look next...

 
cowil:

Hi,

Thanks again for your response. And yes, you're right - the same order fill prices shown with the graphics can also be found in the Journal tab log. So it seems that for whatever reason, the Strategy Tester is massively increasing the fill prices.

I initially thought this may have something to do with a potentially super-inflating spread bug or some such but if this were the case, I would have thought that only the Buy order fill prices would have increased.

I also randomly checked the prices of numerous bars in the chart graphic with the prices in the original quote file - they all definitely match up.

Any other ideas? I'm at a bit of a loss as to where to look next...

This brings me back to my original guess: that the strategy tester is not actually using your EURUSDTest historical price data, but that it is using some other historical price data (maybe the regular EURUSD prices?). In order to see what it is using you would need to scroll back to the beginning of the journal data and see what messages appear about the used data set. If the simulated time frame is too long, you may not be able to scroll back far enough. In that case you can rerun your backtest using a very short time interval: then you can scroll the journal back to its beginning.

I have no hands-on experience with using user-defined historical price data so I don't know how to help further with this.

 
WindmillMQL:

This brings me back to my original guess: that the strategy tester is not actually using your EURUSDTest historical price data, but that it is using some other historical price data (maybe the regular EURUSD prices?). In order to see what it is using you would need to scroll back to the beginning of the journal data and see what messages appear about the used data set. If the simulated time frame is too long, you may not be able to scroll back far enough. In that case you can rerun your backtest using a very short time interval: then you can scroll the journal back to its beginning.

I have no hands-on experience with using user-defined historical price data so I don't know how to help further with this.

Hi,

Thanks again for your reply.

The problem appears to be sort of as you suggested. :-) The journal does show that EURUSDTest was being used throughout the entire simulation. However, your suggestion did trigger some other ideas as to where to look next. And after much playing around, I think I've determined that the problem appears to be a bug with the platform...

The crux of the problem appears to be as follows. When a custom symbol is created and it's quote data file loaded, the quote data is obviously stored under the "...\Bases\Custom\History" directory. When a simulation is then done using the Strategy Tester, the Strategy Tester first copies this quote data to the  "..\Tester\Bases\<Broker>\History" directory and then executes the trading simulation using the data in this directory.

If that custom Symbol is then deleted, the Symbol's data is obviously also deleted from the "...\Bases\Custom\History" directory but NOT from the "..\Tester\Bases\<Broker>\History" directory. If this Symbol is then recreated and a DIFFERENT data set for that Symbol loaded, this new quote set is stored under the "...\Bases\Custom\History" directory as per normal. However, when a trading simulation is then executed, this new quote set is NOT copied over the top of the old quote set under the "..\Tester\Bases\<Broker>\History" directory - the Strategy tester seems to use the old data. Then, when the Strategy tester finishes and goes to display the Trades on the chart, it appears to place the trades made using the old data, over top of a chart created using the new data.

I pretty much verified this by manually deleting the old data in the "..\Tester\Bases\<Broker>\History" directory, restarting MetaTrader (otherwise, even though the old tester data has been deleted, it still seems to be cached somewhere) and re-running Strategy Tester. With the old data deleted, Strategy Tester makes a new copy of the quote data into the "..\Tester\Bases\<Broker>\History" directory (as it should) and everything runs fine.

Anyway, thanks again for your help. I've tried to put a bug report in under "Service Desk" but it doesn't seem to be supported for bug reporting any more? 

 
It sounds like that you made progress. It would be best if this issue could be resolved (if it is indeed considered a bug). Or that otherwise you will be able to find a workaround. Having to manually delete files and restart MT5 isn't really a practical solution in case you want to run multiple backtests.
 
WindmillMQL:
It sounds like that you made progress. It would be best if this issue could be resolved (if it is indeed considered a bug). Or that otherwise you will be able to find a workaround. Having to manually delete files and restart MT5 isn't really a practical solution in case you want to run multiple backtests.

Yeah, nice to determine that it is a potential bug and also be able to replicate it. And the workaround isn't actually too bad, as long as you don't change the quote data for a custom symbol. But yes, it should really be sorted out.

I've contacted someone at Metaquotes - hopefully they'll be able to take a look at it at some stage and pass the details onto the development team. Seems a shame that you can't report bugs directly anymore (under "Service Desk")... :(

Anyway, thanks again for your suggestions!