Knowledge >> What should be known about testing

What should be known about testing

This section describes the basics of Metatrader 4 strategy tester as well as provides useful tricks to make testing easier.

The Metatrader 4 built-in strategy tester is surely a great tool. It allows us to test our strategies very quickly and to visualize the results. However, we must be aware of its limitations and drawbacks:

Only end-of-bar data

The tester does not use real tick-by-tick data. It uses open, close, low and high prices of every bar from 1 minute timeframe. Then, it generates the price movement inside every 1 minute bar using its own algorithm. Although this is good enough in most cases, we must be aware that this is not real data.

Fixed spread

The tester uses the same spread size for the whole testing period. In reality, the spread may change considerably, especially at the time of economic news releases, when the market volatility is higher. Therefore, the testing results may not be reliable.

Instant order execution without any problems

Inside the tester your trading orders are always executed without problems. In real life, the situation is not so good. You may approach all kinds of errors and problems during order execution, like connection losses or requotes. Some operations may need to be repeated a few times and may need at least a few seconds to get done. This may cause your orders to be executed at a slightly different price and time.

No real life limitations

Some brokers limit your trading possibilities in many different ways. The most common limitations are: disallowing hedging, enforcing FIFO rule, changing order comments or disallowing setting of stop losses along with market orders (market execution). None of this will happen in the strategy tester, so you won't know if your EA is really going to work in real life conditions.

Only one timeframe and symbol

Although every EA has access to all data from other timeframes and symbols, only current timeframe and symbol can be visualized in the strategy tester. If your EA uses data or indicators from other currency pairs or timeframes, you won't see the graphical visualization of your trading. Trading is also limited to the current symbol. If your EA tries to send order on a different currency pair, it will generate an error.

Difficult indicator testing

There are times when you want to test indicators, not expert advisors. Most indicators can be tested by simply looking at them, but sometimes you may want to test the alerts they show. It would be great if we could just run the indicator in the strategy tester, but it is not possible. However, it can be done using a simple trick described in the following part.

Update: It is now possible to backtest indicators using the strategy tester. Latest versions of Metatrader 4 have this feature.

Testing tricks

Using templates while testing EAs

Charts in the visual mode of the strategy tester work almost the same way as normal charts. This means you can attach any indicator to them. You just need to pause the test, attach your favourite indicators, adjust their parameters and resume the test. Nothing difficult. The problems begin when you have to do it all over again, because the strategy tester will not remember your settings. So let's use templates. After setting all parameters of every indicator, create a new template (Charts->Template->Save template), name it exactly the same as the tested EA and save it. Next time when you run the test of the same EA, your settings will be loaded automatically. For instance, if your EA file name is My_EA.ex4, the template should be named my_ea.tpl (letters are converted to lower case automatically).

Testing indicators

There is only one thing you need in order to test the indicator in the tester: an EA that does nothing. Then you can run this EA in the strategy tester with the tested indicator attached to the chart. Such EA can be downloaded below. It is called EmptyBot and has only one parameter: Slowing. If you think that the built-in speed slider of the strategy tester is not precise enough, you can use Slowing instead. Just set the speed slider to the maximum speed and adjust your speed with Slowing.

Update: It is now possible to backtest indicators using the strategy tester. Latest versions of Metatrader 4 have this feature.

What you need to know is that testing indicators in the strategy tester may sometimes not work correctly in case of multi-timeframe or multi-currency indicators. But this is rather a programming issue and is out of scope of this article.