Working with the MetaTrader4 Strategy Tester: Mismatch Errors and Quotes Archive in MT4

Master Class "Working with the MetaTrader4 Strategy Tester" - Part 3

Ways to deal with mismatch errors

Как бороться с ошибками рассогласования? Существует два пути: закачка котировок центра исторических данных (History Data Center – HDC) компании Meta Quotes и создание всех временных периодов на основании имеющейся минутной истории.

First way is much easier, but requires Internet traffic costs. To do this you just need to go to the main menu item MT4 "Service" and select the sub-item "Quote Archive." or just click F2. In the opened window choose a currency pair by double-clicking the left mouse button, and then the period "1 minute". After that press "Load", read the appeared message, which informs that the data will be downloaded from the server of the Meta Quotes company, press "OK" and then wait for the end of loading. Upon completion of downloading, you will be asked to recalculate all timeframes (periods), to which you should answer in the affirmative. As a result, we will obtain the history of minute quotes since 1999. It should be noted right away that it will not fully coincide with your broker's quotes history, though it will be similar.

The second way is a little more difficult to implement and gives less of a story, but it will accurate quotes your broker. Open the minute chart of the desired currency pair and swap the quotes history to the end by pressing Home. At the same time, auto-scrolling of the chart should be turned off. Then find the "Scripts" section in the Navigator window (Ctrl+N) and find the "period_converter" script there. Drag and drop it on the currency pair chart. Set the only input parameter ExtPeriodMultiplier to 60 (if you want to create an hour period) and click "OK". Wait a few seconds for the script to work, and then delete the script from the chart - right-click to open the context menu and select "Delete script". To create other periods repeat the operation with the following values of ExtPriodMultiplier: for M5 - 5, M15 - 15, M30 - 30, H4 - 240, D1 - 1440.

Whichever way you choose, you should remember that in order to eliminate the mismatch errors on a fresh history (the one that appeared after history swapping or conversion) you must repeat the described operations.

Test results again

And now let us return to the examination of the test results (see Fig. 4). Of course, the most interesting point is "Net Profit.". But it does not mean much on its own. It must be correlated with the parameter "Maximum drawdown." – это максимальное  количество денег, которое было потеряно. При чем неважно, на каком этапе это произошло – вначале, в середине или в конце теста. Вследствие этого показатель максимальной просадки может быть больше начального депозита (сначала мы заработали, а затем потеряли и заработанные, и начальные средства). The optimal ratio of net profit to maximum drawdown should be about one. That is, we risk about the same amount to make a profit. Although of course no one will object if such a ratio is much greater than unity. In the example above, on the way to earning $100 we lost $40 at some period.

Identical to the maximum drawdown point "Absolute drawdown". – сумма, на которую уменьшался наш начальный депозит. Показатель относительной просадки – это максимальная просадка, позволяющая оценить потери в процентах от начального депозита.

Also of interest are the indicators of "Profitability." и "The mathematical expectation of winning". Прибыльность – это отношение общей прибыли к общему убытку. Чем выше этот показатель, тем лучше (как правило, значения больше двух). В нашем отчете прибыльность отсутствует, так как не было убыточных сделок (то есть вышло значение «плюс бесконечность»). Показатель матожидания – это чистая прибыль, деленная на количество сделок. Он измеряется в валюте депозита, поэтому для анализа лучше переводить его в пункты (для микролотов умножать на 10, для полных лотов – делить на 10). Большие значения этого показателя также более предпочтительны, в то время как малые (меньше 10 пунктов) говорят о том, что стратегия быстро режет прибыльные сделки и долго держит убыточные.

The rest of the indicators should be clear. Let us touch only the maximum number of continuous losses. Based on this indicator, it is possible to judge how long the series of losses in the strategy can be. It is morally very difficult to stand 10 losing trades in a row on a real account. Next to the number of trades in brackets indicates the expression of losses in the currency of the deposit. Take a look at this amount and decide if you can risk that kind of money to make a profit, listed as a net. But in our example there was no series of losing trades, since there are only two trades and both are profitable.

Such a small number of trades is explained by the fact that we applied the simplest testing method. Conduct a test on the "All ticks" model, using the same time period, and see how the number of trades increases to nine (see Fig. 5).

Fig. 5. Strategy Tester Report on the "All ticks" model.
Fig. 5. Strategy Tester Report on the "All ticks" model.

Here it is worth noting that the simulation quality has reached the maximum index 90% (on the minute period the maximum index is 25%). Along with the number of trades the net profit has grown, since we still have no losing trades. But do not flatter yourself - we have just chosen quite a good historical period for this EA. In addition, never take test results seriously with a small number of trades. The minimum sample should be about 100 trades, the optimal sample is 1000. In addition, the historical period should not be less than one year. This will be confirmed by testing this Expert Advisor from the beginning of 2007 to the present day. The situation there is less attractive.

The current test results, even if it is not over yet, can be seen by going to the tabs of the tester window "Results." и "Schedule.". The results line by line shows each conducted operation - opening, modification and closing of an order. Also a separate line displays information about the triggering of stop and profit of the position. If there is a large number of positions opened at the same time, to understand what kind of action was taken on the position, you should look at the value of the column "Warrant."In which each new order or position is assigned a unique number.

The results can be saved. To do this, select the item "Save as report" from the context menu (right-click to call such a menu) of the "Results" tab.

В tab of the "Schedule" tab можно увидеть наглядную историю изменения счета, где синяя линия – это график изменения баланса, а зеленая – эквити (средств которые останутся при закрытии всех позиций). Если тестирование производится не постоянным объемом средств (в нашем примере объем постоянен – 0.1 лота), то в нижней части графика выводится гистограмма изменения объема сделок.

Another important tab of the tester window is "Journal.". The information about the performed operations is duplicated here. All error messages are also displayed here. That is why you should always check it, even if the testing passes without any visible mistakes. The most common error in writing Expert Advisors is attempting to place pending orders too close to the market price, setting stops and profits too close to the market price, and incorrectly changing order or position parameters. The last error is typical of the MACD Sample Expert Advisor. If you look through the entire log, you will surely find the following error message: "MACD Sample EURUSD,H1: OrderModify error 1". The reason is that the Expert Advisor tried to change the stop level several times in Breakeven to the same value. In the future, we will slightly modify the code of the Expert Advisor so that this error will not appear.

In most cases the "Log" tab displays only the latest operations. The entire log can be viewed by opening a file from the MT4\tester\logs folder with the name representing the current date. If you perform one test after another, the same log file will contain information from different test runs. To ensure that the log always contains information only about the current test, you can delete this file yourself or click the context menu item "Erase all logs" in the "Log" tab. In addition, sometimes it is necessary to clear the log files of the tester, because they often occupy a fairly large amount of memory.

Other articles of the master class "Working with MetaTrader4 Strategy Tester"

Leave a Reply

Back to top button