When it comes to choosing a Forex robot, traders usually choose very carefully. It is the best way to not become a victim of a scam. After choosing and comparing here comes the time to start trading with the robot you just bought. And the best idea that might hit your head is to start with the backtesting of the trading system. In this article, you'll learn how to do a backtest of any Forex robot in the MetaTrader4 trading platform.
It is widely believed among traders that tests cannot be trusted, only the results on live trading are suitable. Is it so?
Unfortunately, the strategy tester for MT4 does not provide high accuracy. Even using the best quotes and 99% accuracy of testing, it is impossible to achieve results that would be close to the real because some of the features of the real trading do not take into account in Forex strategy tester. Such as:
- Floating spread;
- Order execution speed;
On the other hand, how much does this all affect the results of a trading robot? There is a simple rule, the more transactions and the smaller the timeframe the higher the influence of “technical” moments. It is better to test advisors with long-term strategies, and scalpers are better to immediately put on real.
In short, the strategy tester for MT4 is a good tool for the overall evaluation of the advisor, but not for predicting its work. Read on how to use it correctly.
So, let’s say you’ve downloaded the best Forex robot and want to know if it is capable of generating income. First of all, you need to check it in the “Strategy Tester”.
Customize MetaTrader and Quotes
The quality test of the advisor for the Forex market directly depends on the quality of quotes that you use. By some manipulations, it is possible to obtain an accuracy of 99.9%. You can read about that in “The simulation quality is 99% in the strategy tester – is it necessary and how to get it”.
In this article, you will learn about a quick way to get 90% accuracy, which is enough for a rough assessment of the advisor's capabilities.
Tip: store the advisors and quotes found/bought on the Internet in a separate MetaTrader. To do this, simply copy the program folder to another location and rename the folder. The new MT4 starts as always through terminal.exe.
Where to download quotes for MT4? There are two ways:
- Direct downloading from the broker’s servers;
- Downloading from the Internet as a file.
Method №1. Download quotes through MetaTrader.
Unfortunately, not every broker has this feature. By default, the program offers to download quotes from the developers of MetaTrader4 – MetaQuotes, and they are not very high quality. But many brokers have this opportunity. To do this, head over to the History Center under Tools or simply hit F2 on your keyboard.
There will appear a window in which you need to select a currency pair, for example, EURUSD. Click "Download" and in a couple of minutes, you'll get more than 5 million entries.
Click “Download” once more to resume recordings, that for some reason didn’t appear for the first time. This should be done every time, and only when the message appears:
Method №2. Quotes from the Internet.
In this case, we need a MetaTrader without a connection to the server. To do this, download the program, open an account with the desired broker, and go to the terminal. So we get the settings that are used in the advisors.
When it is done, log out and forget about the trading account. The MetaTrader will now always be disconnected from the server so that the quotes that we downloaded further do not mix with the new once.
Next, delete the .hst files – File => Open the data directory:
You will find .hst files in history/ “Server name”. Then clean the folder from all files with the name EURUSD.
Most often you can download quotes on the broker’s website, sometimes traders share theirs on the forums. So indicate the minute timeframe and the period for which you need quotes. You can immediately download the .hst file. Download the quotes archive for MT4 and drop it back into history/ “server name”. Restart the terminal.
When the quotes are ready for use, you can start testing the advisor and launch the strategy tester.
How to test an advisor in MT4
In this section of the article, we will discuss how to test an advisor in MT4. We will check the advisors in the "Strategy tester" window. To start test open MT4 platform and click "View", then choose "Strategy tester". You also may use the combination CTL+R to open Strategy tester. When clicking on the “Strategy tester” there should appear a new window similar to the following:
Let’s go over the interface a bit.
“Test conditions” block
- Choose an advisor from the list. If there's no right advisor on the list, you may use our article to learn "How to install the advisor in MetaTrader4 (MT4)".
- It is the currency pair you are going to test the robot for. Usually, the author of the advisor indicates which pairs to work with.
- There are three models for testing Forex robot:
- "All ticks" are the most accurate method, using the smallest available period, i.e. M1.
- "Control points" use the nearest timeframe, which significantly reduces the accuracy of the test.
- “Open price only” for this model it doesn’t matter what happened to the price inside the candle. Open = High = Low = Close. Worst accuracy.
Obviously, it is worth using the "All ticks" model for tests. But sometimes it takes hours to get the result, and in this case, you have to go to the Control Points.
- The period. From minutes (M1) to daytime (D1).
- It sets up automatically if you set “Current”, or just do it manually. Please note – for a 4-digit broker, the spread will be in the region of 1-5 points, and for a 5-digit broker this figure will be 10 times more (10 – 50).
Tip: Look at the EUR/USD pair. If the price looks like 1.2345, then you have a four-digit broker, while 1.23456 is a five-digit one.
The “Data choice” block
1. Use data. Determine the test period, if you uncheck it, the entire available history for the currency pair will be used.
What is the optimal period for proper testing of an advisor in MT4 is a moot point. Personally, 3.5 years is enough for me to evaluate the advisor's performance. Nevertheless, if possible, it is worth setting a longer period. This is especially important for long-term advisors because they rarely make deals. Use the rule, if there are less than 100 deals, you need to increase the testing period.
2. A useful option that allows you to see the work of the advisor directly on the chart.
The speed is set by the slider, and the "Skip to" button is useful if you need to jump to a specific date.
“Testing settings” block
It is another block of the Forex strategy tester:
“Expert properties”. Here are the main testing parameters and the parameters of the advisor itself:
On the "Testing" tab change only the initial deposit. The "optimization" section will be considered in a separate article. Usually, you have to work with the "Inputs" tab.
There are tons of the advisor’s settings, and it’s good if the author described them on the website or in the text file. Presets can be saved to .set files, and then downloaded when needed.
The "Lot Size" parameter is very important for the testing advisor. This is the size of the trading position to be used by the advisor. To compare the effectiveness of different expert advisors in the future, you should always put a lot of 0.1 and an initial deposit of $10.000. This is not taken from the ceiling – so 1 point for a four-sign or 10 for five-sign for dollar currency pairs equals $1.
Another important point is the money management method. For tests, always set a fixed lot (Lot/ Lot Size / Fix Lot, etc.).
- Symbol properties. Information on the currency pair that you have chosen for the tests.
- Open chart. Visual display of advisor transactions and indicators with which it worked.
- Modify the expert. Going to the MQL4 Expert Advisor Editor.
And finally, “Optimization”
What kind of beast is this? In short, this is a function of running the advisor in the same plot section using different sets of settings. Accordingly, the goal is to find the most successful sets (“sets” from .set). There no need to go deep there if you have no knowledge about it. Well, we figured out how to use the strategy tester in MT4. And there is only one thing left to evaluate the numbers obtained.
Test Results Analysis
When the test is finished there will appear three new windows on the bottom of the page (results, graph, reports, and journal). Let's go over them quickly.
The Results tab contains a detailed description of the completed or modified trade transaction, as well as pending orders and trading results.
All actions of the Expert Advisor's automatic strategy have sequential numbering, which is contained in the first column for easy navigation when searching for work failures, as well as the time of operation, located in the second column.
Information about buying and sell orders, as well as about the changed order settings. Stop Loss and Take Profit, profit, and balance, this is what you find on this tab.
On this tab, you can save the report in .html format
The Graph tab is divided into two fields. The first one contains two lines: balance (blue) and equity (green). It's not worth analyzing the chart, the main thing is that it grows smoothly in the upper right corner without large drawdowns. This is what happens in the chart above, but it is obvious that the last 10 deals were completely unsuccessful.
The most important tab that gives the most information. However, keep in mind that the accuracy of the tests is only 90%, the number in real trading will be slightly different.
So, here is the report on the EA test on EURUSD:
We will focus on the most useful and important indicators.
Total net profit. The amount that the advisor has earned. If you divide this number by the initial deposit, you’ll get a return.
Profit factor. It is calculated by the formula Total profit/Total loss. If 1.6 or higher, the EA works fine. We’ve got 1.51 – the advisor is not so good.
Total trades. Must be greater than 100 – otherwise, the test cannot be used, the selection is too small. Increase the testing period.
Modeling quality. Using minute data, we get a maximum of 90%. You can get confused and achieve 99% on tick data. If it is less than 90%, the test cannot be trusted at all.
Maximum drawdown. Maximum losses in dollars, in parentheses, percent of the deposit. If the drawdown is more than 10%, you need to reduce the lot or not use this currency pair at all.
It is also useful, where there are various messages about the work of advisors. It is useful because there you can see the errors of advisors.
As a result of testing through the strategy tester, with normal modeling quality, you will get a clear picture of what the trading robot is capable of, what profit can be counted on, and at what risks it can be received. And remember the most important thing – after testing the automated trading system in the strategy tester and before installing it on a real account, you should definitely try its work on a demo. Only after this robot can be moved to the real account. Good luck with trading!