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

How to deal with mismatch errors? There are two ways: uploading quotes from Meta Quotes' History Data Center (HDC) and creating all time periods based on the available minute history.

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." - is the maximum amount of money that was lost. It does not matter at what stage it happened - in the beginning, in the middle or at the end of the test. As a consequence, the maximum drawdown indicator may be larger than the initial deposit (at first we have earned, and then we have lost both earned and initial funds). 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". - the amount by which our initial deposit was reduced. The relative drawdown indicator is the maximum drawdown, which allows estimating the loss as a percentage of the initial deposit.

Also of interest are the indicators of "Profitability." и "The mathematical expectation of winning". Profitability is the ratio of the total profit to the total loss. The higher this index, the better (as a rule, the values are more than two). In our report, the profitability is absent, as there were no loss-making trades (i.e., the "plus infinity" value has come out). The expectation ratio is the net profit divided by the number of trades. It is measured in the deposit currency, therefore, it is better to convert it to points for analysis (multiply by 10 for micro lots, divide by 10 for full lots). Large values of this indicator are also more preferable, while small values (less than 10 pips) indicate that the strategy quickly cuts profitable trades and keeps unprofitable ones for a long time.

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 you can see a visual history of changes in the account, where the blue line is a graph of changes in the balance, and the green line is equity (funds that will remain after closing all positions). If testing is carried out not with a constant volume of funds (in our example, the volume is constant - 0.1 lot), then at the bottom of the graph a histogram of changes in the volume of transactions is displayed.

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 the MetaTrader4 Strategy Tester"

Leave a Reply

Back to top button