Beginner
Now you are reading
How to properly test automata (expert advisors)?
0

How to properly test automata (expert advisors)?

created Paweł MosionekAugust 21 2013

EA (Expert Advisors) testing on the forex market is a complex issue. How to do it correctly? Trading with automated strategies is a heavy piece of bread, but sometimes it pays to take up this challenge. The very idea of ​​an automaton or finding a ready robot with potential is just the beginning of the work to be done. When we think that everything is ready at this stage, it is time to test the machine in laboratory conditions. To this end, so-called backtests on historical data. How to do it and how to approach it? It will serve us for this Strategy Tester na MetaTrader 4 and 5 platforms.

Historical data

To perform a test on historical data you need to have a database of this data. Usually on the platform we have access to a certain amount of history. Its range may vary depending on the instrument and the time interval (usually the smaller the interval, the shorter the range). The problem is that it is usually not too much. So we have two options:

  1. Download data from the MetaQuotes History Center (tab Tools in MT4),
  2. Look for other data sources on the web.

The first exit seems to be the easiest. A couple of clicks and it's done. Unfortunately, you have to be very careful and this solution has two significant drawbacks - the data is sometimes of poor quality, i.e. it displays various strange prices that have not necessarily occurred on the market and occasionally has gaps in the history. It happens that they are missing a few days or even weeks. If we decide on this solution, it is worth tracing the graph at different intervals and see if there are any such defects on it.

bt3

The second option is ultimately better, especially if you plan to test many robots for longer, but it requires more work. To do this, look for data available on the internet. At one time, many people used Dukascopy tag data that required conversion to the correct format. However, at this moment (August 2013) there was a problem with their easy rework, so it ceased to be so simple. There are other websites that offer such data, e.g. HistData.com. Historical data for backtests should be placed in the appropriate directory, by default it is: Terminal \ tester \ history.


READ NECESSARY: MetaTrader historical data 4. Import of the CSV file


How to perform backtest

Usually each strategy is prepared for a specific market and interval (or their types, e.g. major currency pairs, low intervals, etc.). This is due to the different characteristics of financial instruments and the time perspective of holding transactions (scalping, day-trading, long term). There are few universal strategies that can be used in many different markets and, as a rule, the original design specifies these guidelines. Thanks to this, we know that you don't have to iron all currency pairs in turn at every interval.

Account and strategy configuration

First, we select the parameters at our discretion and assumption (optimization will be dedicated to a separate article). At the same time, the amount of capital and currency of the account on which the test is to be conducted should be determined and whether the strategy should include long and short transactions or only one type (for more unusual machines this option will be useful).

bt1

Environment configuration

The next step is to select the instrument on which the machine will be tested along with the time interval and date range. It is important to choose the range to which we have data. The longer the period, the longer the test will run. Due to the fact that each market changes its characteristics, it is better to test the machine in a different way, i.e. choosing a long period of time and shorter in turn.

bt2

Usually in the tab Model the most accurate method is chosen, but for a quick, demonstrative test you can opt for a more general one.

After configuring the above parameters, you can proceed to the start of testing (button Home). When the green bar reaches the right side, it means that the test has been completed. It is always worth re-testing with the use Visual mode, thanks to which we will see live modeling of the course and the moments of making transactions. This will give us additional confirmation if the assumptions of our strategy were implemented correctly. The speed of the entire action can be adjusted using the slider.


SEE ALSO: Backtesting is definitely not enough. Check your machine


Analysis of results

After completing the backtest, observing the behavior of the machine and finding that everything is in order, you can go on to analyze the results that were generated in report.

  1. First, check whether the technical side of the test ran correctly and there were no errors in it. Single errors in the graph are acceptable and should not have a major impact on the result.
  2. Modeling quality - a low value indicates the use of data of questionable quality. A value from 90% up is considered appropriate and reliable.
  3. At the end, you can get down to what is most interesting to us, the system results. The total profit, loss, capital slippage and other parameters are already analyzed and assessed in their own way. However, it is worth paying special attention to the number of transactions concluded. It is difficult to say that a system test that generated only 5 transactions per year shows the potential opportunities and threats resulting from its operation. The more transactions, the more reliable the result.

You can still evaluate the capital curve, which will show us how the balance of the account (closed transactions) changed in the tested period. Sudden drops and disturbing-looking breakdowns should increase our vigilance and we should check these transactions more closely.

bt4

We will be informed about the possible malfunction of the machine in the tab Diarywhere all the actions that have been taken by EA are displayed. All irregularities are marked with the equivalent of a road sign "No entry".

bt5

What do you think?
I like it
Present in several = 86%
Interesting
0%
Heh ...
0%
Shock!
0%
I do not like
0%
Detriment
Present in several = 14%
About the Author
Paweł Mosionek
An active trader on the Forex market since 2006. Editor of the Forex Nawigator portal and editor-in-chief and co-creator of the ForexClub.pl website. Speaker at the "Focus on Forex" conference at the Warsaw School of Economics, "NetVision" at the Gdańsk University of Technology and "Financial Intelligence" at the University of Gdańsk. Twice winner of "Junior Trader" - investment game for students organized by DM XTB. Addicted to travel, motorbikes and parachuting.