Hello!Mechanical trading systems are as old as the markets.With the development in the 20th century, computer technology and the Internet it has become possible to trade from the comfort of home, and at the beginning of the 21st century, with the advent of the MetaTrader, even in automatic mode.Resources modern desktop allow to implement any, even the most sophisticated algorithms and a built-in terminal MetaTrader MetaEditor editor enables the robot to write even a person who knows little about programming.As a result, okoloforeksovy market is filled with various offers to buy the miracle advisers and some of them are really worthy of attention.But how to understand whether to use one or the other forex advisor on real accounts?Today I'll show you how to test trading robot on historical data using the program MetaTrader 4.
Preparation for testing
We will not discuss today how to install Advisor in the terminal - it has a corresponding articleblog.Let us assume that we have already establ
It is because of differences in the tests quotations of the same adviser on the same pair with the same settings, and other things being equal will likely differ, sometimes greatly.
First we need to set up something for which we go to the Tools tab - & gt;Settings or click Ctrl + O
window appears with terminal settings:
Select the tab "Charts" in columns "Max.bars of history "and" Max.bars in the window "and fill in as I have in the picture above (the default setting is 65000 bars).
To pair the right quotes we have become available in the terminal for test for it, open the Tools tab - & gt;History Center or click F2.
opens the following window:
Choosing the right pair of us and between M1 and presses the button "download".After a while the quotes are loaded, turn off the terminal and turn it on again.Go back to the archive, we click the left mouse button a few times over the period of the M1 required us to pair up until the period of the image before gray battery lights up yellow-green.It is necessary to step through the remaining periods of the mouse to have miscalculated and quotes for them.If you want to test an expert on several currency pairs, upload the required quotes of currency pairs.Close the terminal and open it again.Then re-enter the archive of quotations and go over all periods the desired pair, repeatedly pressing the left mouse button on each of them.All these shamanic action is needed in the latest versions of the terminal, as is often the quotes are loaded incorrectly.At this preparatory stage is completed.
terminal Tester.The main functional
So, to begin testing counselor open Strategy Tester or press Ctrl + R.
Below is such a panel will appear in the terminal:
Let's look at each function in detail.
The first thing you will see on the top left panel - Switch Advisor indicator:
In new builds there was an opportunity to look at the terminal operation of the indicator in a visual mode (which will be discussed below).It must be said that such a possibility had been before, but unofficially.Now under test indicators assigned to separate a button.
So, choose the adviser.
Under number 1 we have is a drop-down list of available testing counselors.Here you will find only those advisors who downloaded to your terminal.Number 2 - the drop-down list of currency pairs, select the desired.Do not forget to upload it to the quotes in quotation archive.If you suddenly can not find the desired pair on the list, but sure that she's broker available for trading, including market overview or press Ctrl + M:
Next, right-click directly in the browser window and click "Showall characters »:
paragraph 3 shall dwell a little more.Here we can select the desired test our model.For qualitative testing trading strategy it is important to choose the appropriate way of modeling development of price bars.Total available three options:
- Open prices only (fastest method to analyze the bar just for advisers with a clear control of the opening bars)
Using a rough estimate of the strategy.Each candle is generated by only one tick.Dignity - the fastest way to check.In this mode, the bar opening is modeled first (Open = High = Low = Close, Volume = 1) what allows the expert to accurately identify the end of the preceding bar.It is this incipient bar starts testing expert.In the next step, the fully completed current bar.
- Control points (a very crude method based on the nearest less timeframe, the results can not be taken into account)
control points modeling method is intended for a crude estimate of experts trading within a bar.For this method, you must have historical data of the nearest less timeframe.In some cases, the available data of the less timeframe do not completely cover the time range of the timeframe under test.If there is no data of a smaller timeframe bar development is generated on the basis of predefined wave templates.
As soon as history data of a smaller timeframe, interpolation is applied to these new data.However, just existing OHLC prices of the less timeframe act as control points.Most experts test results according to the method of control points may be taken into consideration only as estimates and not as definitive.These results are intermediate estimated.
- Every tick (the most precise method based on all available least timeframes)
This is the most accurate method of modeling prices within a bar.Unlike "control points" method uses for generation not only data of the nearest less timeframe, but also all available smaller timeframes.However, if at some time range at the same time there is evidence of more than one timeframe, then used to generate the data of the less timeframe.Just as in the previous method, the generated control data on the basis of the lowest point available OHLC timeframe.To generate price movement between control points and interpolation is used on the basis of pre-defined templates, so it is desirable to have a minute of data covering the entire test range.It is possible that several identical ticks are generated in succession.In this case, duplicated quotes are filtered, and the volume of the last of such quotations.
When testing on every tick volume generated ticks can be quite large, so the terminal can consume a lot of resources.
To test counselor always choose the method of all the ticks.Yes, this is the slowest, but also the most reliable method.Many are used in the control of his advisers close of the bar, that is specially waiting for the opening of a new candle and opening of orders occurs only at this point.But often use advisors foot, Teika, trawls, which may be triggered at any time within the candle.Apply method on opening prices can only advisers who do not use a trailing stop, stop loss and take profit, and open and close positions in the opening of a new candle, and there are very few advisors.
Item 4 - use the date.Put a tick and select the desired start date and the end of the test.If the tick is not checked, testing is conducted throughout the history of quotations loaded into the terminal.The tester will not be able to test on the period for which no quotations in quotations archive, so you will not be able to do a test with 1300, if you have no quotes for this period.
Item 5 - visualization, which we will discuss later.
settings on the right panel of the tester:
Period - the period of choice for testing the expert.Available periods up to D1.W1 and MN1 are not available for testing.In addition, if you have not downloaded the story quotes the desired period, you run the test can not.
spread - can be set to any value or use the current spread on the pair.This is done for convenience - for example, at night and on the weekends the current spread is usually overestimated and if you are testing the adviser at the time, it makes sense to ask spread manually.If you have selected the current spread, the test results may be very different depending on the time of day and day of the week, especially when testing on every tick.
button "Change Expert" is available only if you have the source code of the adviser (extension mq4 file).She opens the editor advisor code, where you can make the necessary changes adviser.
button "Open a graph" opens with a graph plotted on his indicators and transactions made by an adviser during the test (you can press after the test is performed).
Button "Symbol properties»
Change we can not nothing, it's just background information on the used currency pair.
button "Expert properties»
By clicking, you will see a window, the picture above.There are three tabs: "Testing", "Input Parameters" and "Optimization".
Here you can enter is used to test the deposit and the deposit currency.Also, if you wish, you can choose the direction of transactions, for example to allow the expert to trade only in the purchase or sale only.Optimization settings will not be considered under this article.As with the tab "Optimization".
tab "Input parameters»
Here are all the control variables of the expert settings.Incidentally, scalable window - if you pull the mouse over the lower right corner, you can increase or reduce it in size.However, experts tend to normally supplied configuration files with the extension * .set.And often for each pair of your configuration file.To download the correct settings for the desired pair of push the button "Upload" and select the desired file.Often, after the expert settings in the terminal, they are not in the correct folder.After clicking the "Download" button, we find ourselves in the tester folder (mine is C: \ Users \ Silentspec \ AppData \ Roaming \ MetaQuotes \ Terminal \ FE03BE71CD8F9E8F4C70E0FDAFC997E5 \ tester).If the required files were not there, go to the folder FE03BE71CD8F9E8F4C70E0FDAFC997E5 \ MQL4 \ Presets, most likely the files there.So, select and load the appropriate configuration file.Once downloaded, we need to find the parameters of money management advisor and expose fixed lot 0.1 - in this case, every dollar of profit or loss will be equal to 1, the old item.For what it is - I'll tell you below.
Advisor Test.Test results
Now we are ready to test.Check again the settings and press the "Start" button.After some time, the test will be carried out, as we will notify beep emitted rubber-like a child's toy with squeaker.
It is time to look to the lower left corner of the tester:
Here we can notice the tab "Settings", "Results", "Graph", "report" and "log".
tab "Results" available list of all the transactions made by an adviser during the test.
On the "Schedule" you can admire the curve of return counselor.
If an advisor has not made any transaction, you should look at the tab "History".In it you will find a description of everything that happened during the test.It is likely that in the EA any error.For an explanation of the error numbers can be found in the section Error Codes.
tab "Report" is available all statistics work of an expert on the selected time interval:
bars in history - the number of bars in history, shows the depth of history, on the basis of which the simulation was carried out.
Ticks modeled - the amount of ticks modeled, showing the size of the modeled sequence.Each entry sequence is a state bar (OHLCV) at one time or another time.Depending on the timeframe, the modeling method and the availability of historical data of smaller timeframes within a bar can be modeled by a different number of bars states.
Modeling quality - the quality of the simulation.
mismatch errors graphs - errors in the simulation ticks on different timeframes.If there is even one such error, delete the entire history of the terminal and upload again.Delete, you can File - & gt;Open Data catalog - & gt;Open a terminal window with a folder - & gt;history folder - & gt;Select the type of account you want us (the one that you are currently using) - & gt;Close the terminal and delete all files with the extension * .hst.Then upload to re-quotes in the archive of quotations.
Socket with signaling quality of quotations (I have it green, so for example, found on the Internet):
Grey color - missing quotes, red - quotes only the current period, the green - quotes available and previous periods, in this case thanbrighter green color, especially younger periods are available.With the availability period of the M1 indicator will be like me - a bright green.
Initial deposit - the deposit, which was used in.
spread - spread, which was used in.
total profit - how much was earned during Advisor
total loss - how much has been lost.
Net income - income that has been earned by an expert in a given period.If the test is made 0.1 lot, this income in the currency of the deposit is equal to the number of points earned by the old.The same is true for all other parameters specified in the currency.Net profit = Gross profit - total loss.
profitability - profitability, shows the relationship between the total profit and total loss.It is calculated by the formula = Profitability The total profit / total loss.
Expected payoff - mathematical expectation of win.
Absolute drawdown - the difference between the initial deposit and the balance of the smallest value in the testing process.
Maximum drawdown - the maximum difference between one of the highest peaks on balance chart and the closest lowest peak.
The following figure shows the numbers main stages of the maximum drawdown in the testing process.The total value of maximum subsidence in the thick arrows.
Relative drawdown shows the ratio of the maximum drawdown and the value corresponding to the highest peaks.
I think the rest of the test data, such as average profitable trade, the maximum number of consecutive losses, and so on, are quite clear and does not need an explanation here.
If you click on the report, right-click, you can save the report as an html file:
top of the report are the main data on the conditions of the test - period, the currency pair, the test model, the expert and so on.Below - statistics and test graph of the yield curve.Further, as the table is a list of all completed transactions.
This mode provides the ability to literally see in the accelerated mode as in the past would work adviser to the changes of quotations that have taken place.