It is always worthful to backtest a trading strategy before implementing it, 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.
The backtesting option is available on both MetaTrader 4 (MT4) and MetaTrader 5 (MT5) version.
A user can backtest
- 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.
Open backtest settings:
After opening your MetaTrader trading software. Press control + R to open the backtest display panel.
1. Select type
Indicator or expert advisor.
2. Choose name
Select indicator or expert advisor name.
3. Select symbol
Choose currency pair or symbol.
4. Select Mode
Here you will find three options for modes.
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.
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.
5. Use date
If 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.
This is basically the time period. You can use any timeframe you like which are available on MetaTrader.
Here 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 properties
With this option, you can choose indicator or expert input parameters based on your needs.
9. Symbol properties
It shows selected symbol properties.
10. Open chart
This option opens the chart with the selected date range.
11. Modify expert
This opens the coding part of the expert advisor (EA) or indicator. This option is basically meant for program developers.
Lastly after setting up everything you need to click on the “start” button to start the backtesting process.
This 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 display
If 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 to
Clicking on this buttons enables users to skip to the end date during visual backtesting.
Optimization in detail
Optimization means finding the best profitable set up for testing an automatic system or expert advisor. More like pattern searching.
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 the example below, 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.
In this section, 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.
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, then finally stop means where it will stop changing the value step by step.
Pre added with default value, but you can change it, if required.
For better optimization, you need to select Model as control points instead of the tick by tick or open price data.
So now, we have started an optimization process with two factors, moving average period and moving average shift period.
The default shift value is 0 and the default moving period is 200.
It 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 is also starting from zero then increasing by 1000 then last up to 5000.
Therefore after completing the test, we will see optimization data is added in both graph and result sections.
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.
If you tick more than 2 optimization inputs, then it will take a longer time depending on EA’s input settings.
Backtesting is a must for all responsible trading. No matter you bought a custom indicator from any marketplace or you have design one for yourself. Backtesting lets you know whether your indicator or automatic system will work or not in past charts.
An optimization gives a special edge to find out the best possible settings for an expert advisor. Optimization also helps to understand the automatic system stability in the long run.
Therefore these all will give you the confidence to try it on the live market with forward testing. Also, allows you to filter unprofitable indicators or EAs and saves your money.
Need pro tips on the MetaTrader trading platform? So here you are with advanced strategies to move your forex trading, next to the success edge.