Contents:

What is backtest in Metatrader?

Backtest, worthy of testing before implementing your trading strategy on your real trading account. With the MetaTrader backtesting feature, a trader can understand better how a system works on historical data or past charts visually. If you are new to this, then worry not! As you are going to be a backtesting expert in the next 5 mins.

Prefer to watch the video version?

YouTube player

The backtesting option is available on both MetaTrader 4 (MT4) and MetaTrader 5 (MT5) version.
A user can backtest the followings:

  • Indicator (default or custom)
  • Expert advisor (EA)

Here default means, by default MetaTrader comes with some preset indicators like Bollinger bands, moving averages, etc. So you can test strategies with default indicators also.


How to open backtest window?

After opening your MetaTrader trading software. Press control + R to open the backtest display panel in metatrader platform.

Backtest components:

metatrader backtesting on tester
Image 1: Metatrader backtesting testing an expert advisor (EA)


Refer Image 1:

OptionDescription
1. Select typeIndicator or expert advisor.
2. Choose a nameSelect Indicator or Expert Adisor (EA) name
3. Select symbolChoose a symbol from the dropdown list
4. Select ModeHere you will find three options for modes.
Every tick
Its a slower process as it backtest tick by tick. But yet the most accurate one. If you have selected this option, make sure that, you have tick data downloaded from history center to execute backtest on a given date. In short you should have past data available for the backtest.
Control points
Back test with nearest least timeframe data. Some trader prefers it based on their trading strategy.
Open price only:
This option enables MetaTrader to backtest historical data, based on the candlestick or bar open price. As it takes only the opening price of each bar, therefore it is faster than other modes.
Control points
Back test with nearest least timeframe data. Some trader prefers it based on their trading strategy.
5. Use dateIf you tick on the ‘use date’ option, then it will allow you to select the start date (from) and end date (to), thus enabling you to use a custom date option. On the other hand, if you do not use the date. Then by default MetaTrader software will start backtesting it, with all available historical data previously loaded on MetaTrader.
6. PeriodThis is basically the time period. You can use any timeframe you like which are available on MetaTrader.
7. SpreadHere you can either choose any default spread value or you can customize it according to your need, so you can choose the ‘current’ spread value during the active market hour.
8. Expert/indicator propertiesWith this option, you can choose indicator or expert input parameters based on your needs.
9. Symbol propertiesIt shows selected symbol properties.
10. Open chartThis option opens the chart with the selected date range.
11. Modify expertThis opens the coding part of the expert advisor (EA) or indicator. This option is basically meant for program developers.
12. StartLastly after setting up everything you need to click on the ‘start’ button to start the backtesting process.
13. OptimizationThis option is mainly for the expert advisor. Because with this option user can optimize each backtesting result with different input parameters of the EA. Then compare, which one performed best.
14. Visual displayIf you tick on the display visual option. Then it will draw a chart and show you the backtest process as a live version. In the case of indicator backtesting, it will draw the indicator on that chart.
15. Skipped toClicking on this buttons enables users to skip to the end date during visual backtesting.

What is Optimization in Metatrader?

Optimization means, finding the best profitable set up for testing an automatic system or expert advisor. More like pattern searching.

metatrader optimization select option
Image 2: Metatrader optimization select option

Metatrader 4 has the basic optimization setup which is easy to understand. But MetaTrader 5 has a little bit more complex, system which we will cover in the next article.

If you enable optimization, then in the strategy tester window, it will open two new tabs, one is for optimization results & one is for optimization graph.

With reference to Image 2 (given above), we are going to test the moving average EA with its default setup.
Upon clicking on the ‘Expert properties’ button. Here you will see 3 tabs.


Tab NameDescription
TestingHere, you can choose the initial deposit for testing your automatic system. Also, you can choose whether you will be testing it only with buy trades or sell trades or both. Next, if optimization is selected, then you can choose any parameters for optimization.
InputsThis tab contains different input parameters with 4 parts. Value, start, step and stop. Here ‘value’ indicates default value, ‘start’ means the starting value, ‘step’ means as the automatic system will keep running, how the input value will change in each step, and finally ‘stop’ means where it will stop changing the value step by step.ization.
OptimizationPre added with default value, but you can change it, if required.This tab contains different input parameters with 4 parts. Value, start, step and stop. Here ‘value’ indicates default value, ‘start’ means the starting value, ‘step’ means as the automatic system will keep running, how the input value will change in each step, and finally ‘stop’ means where it will stop changing the value step by step.ization.

Table 2: Three tabs of Expert Advisor’s properties.


Quick Tip:

For better optimization, you need to select Model as control points instead of the tick by tick or open price data.

Optimization process:

So now, we have started an optimization process with two factors: moving average period and moving average shift period.

metatrader ea optimization
Image 3: EA optimization input

The default shift value is 0 and the default moving period is 200.
EA will start with the default value, then in each step, it will change by adding more than 100 periods until 600 periods moving average.

Moving average shift also starts from zero then increased by 1000 then ends at 5000. Refer Image 3. Therefore, after completing the test, we will see optimization data is added in both, the result(Image 4) and graph (Image 5) sections.

Metatrader EA optimization result
Image 4 : Metatrader EA optimization result
metatrader optimization graph
Image 5: Optimization graph with profit

It seems, with moving average period 200 and 4000 moving average shift period, automatic system has generated some profit. Only that was the best setup based on the optimization parameters with profit.


Quick Tip:

If you tick more than 2 optimization inputs, then it will take a longer time depending on EA’s input settings.

How Can Backtesting Strategy Help?

Backtesting is a ‘must’ for all responsible traders. No matter how many custom indicators you bought from any marketplace or have designed one for yourself, backtesting lets you know whether your indicator or automatic system will work or not in past charts.

An optimization helps to find out the best possible settings for an expert advisor, also helps to understand the automatic system stability in the long run.

Therefore, building your confidence in trying it on the live market.



[wbcr_html_snippet]: PHP snippets error (not passed the snippet ID)

error: Content is protected !!