In this tutorial we are looking at how to use MT4 Strategy Tester for both a regular backtest and an optimization.

How to use MT4 Strategy Tester

To open the Strategy Tester, from the top menu open ‘View’->’Strategy Tester’. From the top left corner of the Strategy Tester window select whether you are testing an Indicator or an EA (during this tutorial we will focus more on the EA backtest since this involves trades as well). Then you are free to select the desired file, period, spread, symbol and timerange. Also enable the ‘Use date’ and ‘Visual mode’ box. For the ‘Model’, it is suggested to use the ‘Every Tick’ mode since that’s the most precise one. To learn how to install an EA or an Indicator into the MT4 for backtesting, you can view our tutorial on that HERE.

MT4 Strategy Tester screen

Click on the ‘Expert properties’ button. From the ‘Testing’ tab you can set the balance you want the test to be carried out with. On that tab you can also choose the currency and whether the EA is allowed to take both long&shorts or either one of them.

In the ‘Inputs’ tab, make sure there are no ticks in the boxes before the variables. The EA uses the values set in the ‘Value’ column for the strategy test. You can leave the other 3 columns untouched. If you wish to save the setup, you can do that by clicking ‘Save’. If everything is in order, click ‘Ok’ and hit ‘Start’. You can adjust the speed of the backtest using the controller between the ‘Visual mode’ tick box and the pause button. You can pause the test using the ‘Pause’ button.

MT4 EA backtest setup

Once the test has been finished, you can observe the trades taken in ‘Result’ tab. You can observe the balance and equity graph in ‘Graph’ tab. The ‘Report’ tab contains lots of information about the backtest as well. In the ‘Journal’ tab the strategy tester logs out all the actions and errors. If there is a bug and you want to notify the developer of it, please right click on a line in the ‘Journal’, click ‘Open’ and look for the file with the correct date the test was ran on (the format is ‘YYYYMMDD’).

How to use MT4 optimizer

If you wish to test several setups of the EA to find the best one, you can let the computer do the heavy lifting and use the optimizer which runs through all the possible setups and gives you the results for all of them.

Open the strategy tester and make sure you have ticked the ‘Optimization’ box. You should set every other settings like you did with regular strategy testing (period, currency, program etc).

In the ‘Inputs’ tab of the ‘Expert properties’, tick the boxes in front of the variables you wish the optimizer to test through. There are no limits to how many variables you tick. For those variables you have ticked, you need to set the ‘Start’, ‘Step’ and the ‘Stop’ value. The strategy tester uses those and ignores the ‘Value’ column. For all the values that were not ticked, the strategy tester uses the ‘Value’ column for their values.

In the below example, the strategy tester runs through all the possible setups and for the ticked values (‘First orders TP pips’ and ‘Third orders offset pips’), it starts to modify the variable itself with each test. It starts with the value in the ‘Start’ column, moves on with an amount set in the ‘Step’ column and finishes with the value given in the ‘Stop’ column. The more possible scenarios the strategy tester needs to run the more time it takes to complete the test. An optimization can take anywhere from a couple of minutes to several days to complete. Once the settings have been set, click ‘Ok’ and start the test. You will not be able to see the chart ‘running’, you will only see the results of each test. (NB! The tests that end up in negative will be ignored by the strategy tester and they will not be visualized for you.)