Expert Advisor Testing

It’s important to back test an expert advisor to get a idea of it’s performance because no one wants to set an expert advisor loose on a live account if it’s likely to lose money. Also an expert advisor isn’t guaranteed to perform as well as it has in back tests when it starts trading live or demo. So the order of testing is this, you back test and optimise over a sample period of at least a year, then from your optimisation results you test out of sample on the last two years or more which gives you a good idea if the settings have been subject to over fitting. If at this point you find a setting that produces a steady profit curve you have something you can start forward testing on a demo account. Once you are satisfied that the expert advisor is performing as expected with similar characteristics to the back tests then you can proceed to live trading using small lot sizes. If everything goes smoothly and the expert advisor is performing well on a live account then you can increase the money management setting anywhere from 0.01 to 0.03 depending on your preference for profit and volatility.

Testing Using MetaTrader 5

With MetaTrader 5 use of tick data isn’t possible but their tick generation algorithum from M1 data should give good indication of performance, but you should be aware that it’s sensitive to close trailing stop usage. MetaTrader 5 has a greatly improved tester with multi core optimisation and the option to use multiple computers on your network to speed up optimisation compared to MetaTrader 4. Other than the improvements testing is similar to MetaTrader 4.

Testing Using MetaTrader 4

By default MetaTrader 4 uses bar data and generates tick data using an algorithm which is not accurate and can be tricked into producing good results in back tests and bad results when live/demo trading. Back testing without using tick data will result in inaccurate results because MetaTrader reduces the number of ticks and speeds up the back testing but results in stops not being hit when they should have been. You must always use real tick data by downloading data with SQ Tick Downloader and exporting to MetaTrader using Tickstory Lite. Always export the correct time period that you are going to run the EA and that the EA time period settings match, not doing so can produce strange results or even fails to test at all.

Downloading Tick Data

First download SQ Tick Downloader and run the application. Now click on the date range in the list of currency pairs for the one you are interested in downloading and select the dates you wish to download. Making sure the currency pairs that you wish to download are ticked on the left click on the “start download” button. The download will take a while because data size can be somewhere in the region of a gigabyte per year.

Once you have downloaded the tick data, it’s time to download and run Tickstory Lite so that you can export this data to MetaTrader. Tickstory lite is an old version and can’t launch MetaTrader but don’t worry you can still export the tick data and it’s available in MetaTrader as soon as it’s finished exporting, you don’t even need to restart MetaTrader. First go into Tickstory¬† settings and set the store location to the same location as SQ Tick Downloader, and also set the MT4 data folder location, this can be found by opening your data folder by selecting “File->Open Data Folder” in MetaTrader. Right click on the currency pair you wish to export and click export to MT4. Select the date range and deselect all FXT time frames except the period you require to save HDD space and click ok. The files are exported to the “tester\history” folder within your Meta Trader data folder. Once they have been exported you need to check that the .fxt files have been set to read only otherwise Meta Trader will overwrite the files and not use the tick data you have exported. Do this by right clicking on the file and selecting properties from the popup menu. Then make sure the read only check box is ticked. Now you can proceed to back testing and optimising in MetaTrader.

Installing Expert Advisors

To install an Expert Advisor, open your data folder by selecting “File->Open Data Folder” in MetaTrader. Then add the Expert Advisor file to the “MT4\Experts” folder, then go to MetaTrader and right click on the Expert Advisors category in the navigator and select refresh. Expand the Expert Advisors navigator category if it isn’t already and you should find the Expert Advisor in the list. You can now drag or double click to add it to a chart window, it will also appear in the tester drop down selection.

Back Testing & Optimisation

The MetaTrader back tester and optimiser is used to test Expert Advisors and find settings that produce the best results. You start by selecting the Expert Advisor you want to test from the drop down menu in the tester window. Then select the currency pair and every tick for the model and the required period and 10 for Spread. Now click on Expert properties button and choose the settings to optimise and select the inputs tab. Only optimise using a fixed lot size so that the net profit isn’t weighted to the end of the testing period and it will give comparable results. Choose as many fixed settings as you can and only select a few settings to optimise by ticking the check boxes on the left. For each of the settings that you are optimising, choose start, step and stop values to test through a range of settings that you think will be relevant. Now select the testing tab and select genetic algorithm if you want to attempt to speed up optimisation by letting MetaTrader decide if setting ranges are irrelevant due to bad results. This is normally okay to select, but deselect if you want to test the entire range of settings. Now make sure that the optimisation check box is ticked and click the start button. Under the optimisation results tab you should start to get results, and the optimisation graph should begin to fill. Once complete go to the optimisation results tab and click on the profit column header to order by profit so that it’s in descending order. Work your way down from the top of the list, right click on the row and select “set input parameters”, this will set the tester into normal testing mode, and if you click on the start button it will back test the period and show you a graph and results summary. You are looking for settings that perform well out of sample with a maximum draw down of 30% when using money management. The higher you set the account risk the higher the draw down will be.

An important thing to check in the results summary is that the quality bar is all green, this means you are using tick data and not accidentally using fake tick data produced from M1 or higher bar data.