The Expert Advisor is not tested. How to Test Expert Advisors in MT4 Correctly? Automatic testing of Forex strategies
Technology is advancing at an ever-increasing rate.
Previously, market analysis was carried out using quotes that were received by telegraph tape, charts, hand-drawn on graph paper. It was a long and laborious process, when preparation for the analysis took longer than the analysis itself.
Computer technology has changed and continues to evolve, making it possible for everyone to access market data and trade right from home. At the same time, modern terminals have a wide range of tools for analyzing the market situation. And, if earlier the question was how to get access to the market in order to make at least some kind of overview of the market situation, now the main task is what to choose from the available variety of analysis tools.
In addition, automated trading has become available to everyone. Modern trading terminals have development environments that allow even people who are not deeply familiar with programming to create trading robots. Therefore, the market for robots for automated trading is now replete with all kinds of expert advisors.
Among them there are many who can really bring nice results... But in order to understand how effective these robots are, you need to test them and make sure that, at least on past historical data, they showed stable results. After that, you can already proceed to testing on the real market and directly on the trading itself.
The MetaTrader terminal has a built-in strategy tester, on which you can test the forex advisor with obtaining detailed statistics on the results.
Preparation
You can read about how to install an advisor to the terminal in this article.
For testing to be correct, first of all, it must be carried out on high-quality quotes.
Most brokers do not have their own quotes archive; they use quotes from MetaQuotes, the developer of the MetaTrader terminal. This is far from the best quality data; their quotes archive is full of gaps and inaccuracies. Data from testing on such data will not be practical and may differ greatly from the results that would be in the real market.
For example, the brokers Ducascopy and Alpari have their own archive of quotes. For the second, in order to get it, you need to have a real account, and not a demo account, access to such quotes is not provided.
First of all, you need to make basic settings.
You need to press Ctrl + O or use the mouse to select the menu "Service-> Options".
In the "Settings" window that opens, select the "Charts" tab. In the items “Max. bars history "and" Max. bars in the window "we prescribe 1,000,000,000.
Then go to the menu item "Service-> Quotes Archive". It can be invoked by pressing the F2 key.
A window will open where you can select the desired currency pair and time interval. Select the period M1 and click "Load".
After the quotes are loaded, you need to restart the terminal.
Then we again go to the Quotes Archive menu, again select the required currency pair, click on the m1 period, until the icon to the left of it turns yellow-green.
After that, you also need to go through all the other periods of this currency pair so that the quotes are miscalculated for them for everyone.
If testing will be carried out for several currency pairs, then these manipulations need to be done for each of them.
That's all with the preparation.
Strategy tester and its basic features
Pressing Ctrl + R opens the strategy tester panel. You can also call it by pressing the corresponding key in the top panel of the terminal.
The working panel of the strategy tester will open at the bottom of the terminal:
On the top left, there is an item where, by clicking the mouse, a menu drops out and you can choose what you want to test: an Expert Advisor or an indicator in the visual viewing mode. In our case, select the "Advisor". And opposite this item on the right in the drop-down menu, you can select the advisor itself, which you want to test. But, of course, only those advisors that are installed on your terminal are available for selection.
In the "Symbol" field, you select a currency pair or any other financial instrument that is in the terminal, and the broker provides its quotes. If suddenly you cannot find the desired pair, but you know for sure that it is, then go to the "Market Watch" window on the top panel of the terminal, right-click in it, and then select "Show all symbols" from the menu.
In the "Model" item, you can select the way how quotes will be displayed and how candles or bars will be drawn.
The following types of graph simulation are available for testing:
- At opening prices. With this method, the bars are drawn entirely in one tick at once. And there is no real-time information about how the price behaved during the formation of the candle. Candles are drawn quickly, which speeds up the process. But this method is only suitable for testing those Expert Advisors where control over the opening of bars is needed.
- Control points. Also a very rough way of assessing. To simplify, it takes data from the previous timeframe, namely OHLC prices (that is, Open, High, Low and Close), and based on them, the construction of the bar is modeled. Its readings can only be used for evaluating the EA, but not for full testing.
- Every tick. This method already uses prices not only from the nearest lower timeframe, but also from all lower time intervals. If there is data from several timeframes for the formation of a certain period of time, then the lowest one is taken. If suddenly there is no data between the points, then interpolation based on the specified templates is used. If suddenly the quotes are duplicated, then filtering occurs, and the volume of the last quote is taken. This method is more demanding on resources, which can significantly load the terminal.
As it becomes clear, the latter method is the most reliable and accurate for testing most Expert Advisors, because it provides more accurate price data, as close as possible to market conditions.
Further, in the "Use date" item, you can select the testing period by time. If this item is not touched, then the tester will test all the quotes that are available to him. If you check the box next to it, then the fields will become available in which you can specify the beginning and end of the time interval for which you want to conduct testing.
On the right side of the tester panel there are also several items for setting up testing.
In the "Period" item, select the timeframe on which the testing will take place. The maximum available for testing is D1. And it is imperative to download the history of quotes of the exact time interval on which you are going to carry out testing.
In the "Spread" field, the current spread will be selected by default. If you need to test an advisor that, for example, trades at night, and your broker has an increased spread at this time, you can manually set its value of interest.
If you have an Expert Advisor file with the .mq4 extension available, you can click the "Change Expert" button, thereby calling the code editor, where you can make your own edits.
After the end of the test, the function of the "Open chart" button becomes available. Pressing it opens a chart of the pair with the advisor's indicators and the deals that it made during testing.
By clicking "Symbol Properties", you will open an information window with the specification financial instrument on which to test.
Expert Properties brings up a window with three tabs, as in the screenshot below.
In the "Testing" tab, you can change the size of the deposit and the currency of the account. You can also instruct the advisor to open only purchases, only sales, or both.
The "Input parameters" tab displays the settings of the Expert Advisor. If the advisor already has ready-made settings presets, for example, for certain pairs and time intervals, then they can be uploaded by clicking the "Load" button and selecting the settings file with the * .set extension.
The "Optimization" tab will not be analyzed, just like the process of optimization of the Expert Advisor itself. This is a separate deep topic that does not go into the scope of this article.
The last thing to do before starting testing is to set a trading lot of 0.1 lot, so that each change of 1 point in the old four decimal places equals 1 dollar. This will be useful as you test and evaluate the results.
Testing process and analysis of results
Pressing the "Start" button starts testing.
When it ends, the buzzer sounds for a child's rubber toy.
To evaluate the results, the tabs at the bottom of the strategy tester panel help us: “Settings”, “Results”, “Graph”, “Report”, “Journal”.
In the Results, you can find a list of all the advisor's trades for the testing period and the results for them.
In the Chart, a yield curve is drawn, by which you can quickly assess the stability of the advisor's trade, the rate of growth of the deposit, and other points.
The Log displays system messages about events during testing. If something is wrong with the advisor, and some kind of error has occurred, then this is where you can find information about it.
The Report contains all the important statistics.
Bars in history- how many bars were taken for testing during the selected time period.
Ticks simulated- the number of recreated ticks, taking into account data on Open, High, Low and Close prices and volume (volumes). This amount may vary depending on the testing model, time interval and the quality of quotes.
Modeling quality- displays quality as a percentage.
- shows if there are errors when recreating ticks at different time intervals. There should be no mistakes, otherwise the results will be far from reality.
If there is at least one error, you need to update the quotes archive. First, you should delete the old archive. To do this, click "File -> Open data directory -> History -> select the folder of the current trading account -> close the terminal without closing the folder -> delete all .hst files".
Then we update the quotes archive again, as described at the beginning of the article.
An example of how errors are displayed on the graph mismatch errors panel below.
Quotes that are lacking are shown in gray, quotes from the current time interval are shown in red, quotes that are available both on the current and on lower time intervals are shown in green. Smaller time intervals are shown in brighter green.
If there are no errors and quotes from m1 are available, then the entire scale will be bright green.
Initial deposit- the initial start amount.
Spread- the one on which the advisor was tested.
Total profit- how much is earned.
Total loss- how much is lost.
Net profit Is the difference between total profit and total loss. When testing 0.1 lot, every dollar of profit is equal to 1 point earned.
Profitability= total profit / total loss.
Expected payoff- speaks for itself.
Absolute drawdown- shows the difference by which the balance fell from the initial deposit.
Maximum drawdown- the maximum difference between the highest point of the advisor's yield curve and its lowest point.
Relative drawdown= maximum drawdown / value of the highest point of the advisor's yield curve.
What the rest of the data show is easy to understand from their names and indications.
Rendering mode
If this item is checked, then after pressing the "Start" button, a separate chart will open, on which candles will be drawn in accelerated mode based on previously loaded quotes from the archive.
Such a visual mode is convenient if you need to see with your own eyes how the advisor worked out certain moments in the market, how it opens and closes deals. That is, it can be better understood there.
If you know which indicator the Expert Advisor is based on, then you can add this indicator to the visualization chart and check the quality and accuracy of the Expert Advisor's entries.
Alternatively, you can watch it live. how an advisor behaves at some critical market moments or at the time of important news release.
In short, by getting visualization, you have more control over the testing of any robot.
Conclusion
It should be said that this method of testing Expert Advisors is more suitable for robots that work on intervals from m30-h1 and higher.
For scalping robots that trade on lower time intervals, other testing methods are needed, where the quality of modeling is much better, more precisely, closer to the real indicators of the broker's market quotes.
For those who need to test any manual trading systems on the tester in an accelerated mode, the tester is suitable. TradeSystem2, which has a number of convenient advantages in comparison with the standard tester of the MetaTrader terminal.
Today we will consider the issues of testing and optimizing Expert Advisors in the MT4 trading terminal.
The strategy tester will open in which we will test our Ilan16c_PipStepExponent_MFI_lock.
In the upper-left tab of the strategy tester, select “Expert Advisor”.
In the tab next to it, in the drop-down list, look for our advisor and double-click on its name.
In the tab below, select a symbol - a currency pair for which we want to test the advisor. Let's have USDJPY.
Choosing a testing model - choosing the most accurate "Every tick" method. “Control Points” and “At Open Prices” are models that are more suitable only for a cursory analysis of the EA's work.
We put a tick on "Use date" - set the interval. Let us have an interval from the beginning of 2015 to 2015.11.23.
The next item is "Visualization".
You can check the box for visualizations, or you can leave it unchecked. A check mark on the visualization means that you will see the entire process of testing the Expert Advisor on the selected history interval right on the chart.
Set the testing speed to maximum - move the slider all the way to the right.
Pause / Play and Skip to buttons are also available.
We move our gaze to the right in the tester.
We make a choice of a time period - on which we will test the robot. Let's have an M5.
Now let's open the Expert Advisor settings - click "Expert Properties".
Here we see the standard settings of the Ilan16c_PipStepExponent_MFI_lock advisor - we will test with them. You can change the settings of the expert as you want and only then test it. Any Expert Advisor can be tested an unlimited number of times and.
On the "Testing" tab, you can select the size of the deposit for testing and its currency, as well as specify which positions to open: buy and sell, buy only or sell only.
Let the initial deposit be 10,000 USD, and the positions: buy and sell (Long & Short) - this should always be the standard in MT4.
Attention: in order to test the Expert Advisor on a decent history with high quality modeling, we need to load quotes for the symbol used in the tests. In our case, we need to download quotes for USDJPY.
This process also comes in handy for optimization. trade expert... You need to download the archive of quotes for any instrument only once.
How to upload an archive of quotes to MT4?
In the uppermost menu of the terminal, click "Service" and then "Quotes Archive". Or just press F2.
A window with archives of quotes for available instruments will open.
We are looking for our symbol (our currency pair) USDJPY in the list and double-click on its name, and then double-click on "1 Minute".
Press the button "Download". The process of downloading all quotes for USDJPY will begin - for all timeframes.
That's it - all quotes for USDJPY have been downloaded - now you can qualitatively test and optimize EAs at all ticks.
We close this window and try to test our advisor Ilan16c_PipStepExponent_MFI_lock - press the “Start” button.
Quotes are loaded from the quotes archive.
What's the bottom line? Draining the entire deposit.
As you can see, the standard settings are clearly not suitable for us - we will have to optimize this EA.
Note: you can save any report to your computer - go to the "Report" sub-tab of the strategy tester, where we display all the data about the passed test, and right-click in this window, and then "Save as report" - the report will be saved in HTML format ...
Click "Expert properties" and put a checkmark in front of those parameters that will take part in the optimization - put a checkmark on the parameters that are more significant for us.
Also, we put down in front of the parameters with checkmarks their "Starts", "Steps" and "Stops" - in simple words, limit of values from and to with a step.
On the "Testing" tab, you can select the size and currency of the deposit, as well as specify the types of positions to open: purchases and sales, only purchases or only sales.
An optimized parameter is a certain indicator, the value of which determines the quality of the tested set of input parameters. The higher the value of the optimization criterion, the better the test result is estimated with a given set of parameters. The following optimization options are available:
- Balance: the indicator of optimizedness is the maximum value of the balance;
- Profit Factor: the indicator is the maximum value of the profit factor;
- Expected Payoff: the indicator is the maximum value of the mathematical expectation of a payoff;
- Maximal Drawdown: the indicator is the minimum drawdown value;
- Drawdown Percent: the indicator is the minimum value of the relative drawdown (in percent);
- Custom: when this parameter is selected, the value of the OnTester () function in the Expert Advisor will be taken into account as an optimization criterion. This parameter allows the user to use any custom metric for optimization.
A checkmark opposite the genetic algorithm - it is recommended to leave it with a checkmark. If there is no check mark, then be sure to check it. If you leave this box unchecked, you will wait forever for the Expert Advisor to be optimized, since absolutely all combinations of the Expert's input parameters will be sorted out.
Optimization tab. It allows you to manage constraints during optimization. If any of the conditions is met during a separate run, this run of the advisor will stop. Optimization will continue from the next run.
To enable a limiting condition, you must select the corresponding checkbox to the left of it. By double-clicking the left mouse button in the "Value" field, you can change the existing parameter, after entering the new value, press the "Enter" key.
Limiting parameters include:
- Minimum balance: the minimum value of the balance in the currency of the deposit;
- Maximum profit: maximum profit in the deposit currency;
- Minimum margin level%: minimum margin level in percent;
- Maximum drawdown%: maximum drawdown in percent;
- Continuous loss: the maximum cumulative loss in one series. Several consecutive losing trades are called a losing series;
- Continuous number of losing trades: the maximum number of losing trades in one series;
- Continuous Win: the maximum total profit in one series. Several profitable trades in a row are called a profitable series;
- Continuous number of profitable trades: the maximum number of profitable trades in one series.
After all the changes, click on the "OK" button.
We put a tick on "Optimization" and press "Start".
The optimization process has started - as you can see from the screenshot, there will be 10,496 passes, with an optimization time of almost 175 hours ... But we will not wait so long - as soon as we see an excellent option / options (for example, with a solid profit and an acceptable drawdown), we can stop the optimizer.
Open the "Optimization Results" tab and observe the process. The runs will line up vertically in a row. You can sort any cell - left-click on the header of the desired cell and the values will be sorted in ascending order from top to bottom, click on the header again and the values will be sorted in descending order from top to bottom.
I think 10 positive passes of the optimizer will be enough for the example. Stop the optimizer - the "Settings" tab, the "Stop" button.
So what do we see? We have some good passes, but the best one is the top-most — the highest profit and the smallest drawdown of all 10 passes. We will take these settings.
The settings in the Expert Advisor from the optimizer can be implemented in two ways: double-click on the desired pass (left button) or click on the desired pass with the right mouse button and then "Set input parameters".
Remember our advisor lost the entire deposit? Well, now we press the "Start" button and test the Expert Advisor with new optimized settings.
Great, isn't it? The settings turned out to be excellent.
We open on home page of the strategy tester "Expert properties" and click the save button - we need to save this file with the settings for ourselves, so that later it can be used with this Expert Advisor on different terminals at any time.
We select where we will save the file and come up with a name for it, then press the "Save" button. In this case, the file will be saved to the desktop.
To embed any file with settings in an advisor in the strategy tester, click on the “Expert properties” button and then “Load” - specify the path to the file, select the required file with the mouse and click “Open”. The settings will be integrated into the Expert Advisor - after that do not forget to click on the "OK" button in the Expert Advisor properties.
The results of this optimization testing and the settings file are included in the EA archive.
Now you know how to test an Expert Advisor and how to optimize it correctly. Good luck!
Testing Expert Advisors is a key factor in effective automated forex trading. When buying or downloading a forex advisor from any site, you should think about whether it is really as profitable as they say. You cannot risk your deposit without making sure you can protect it. In the case of trading with Expert Advisors, the main trader's assistant is and your future activities depend on how competently you know how to handle it. In this article, we will not touch upon the issues of optimizing the selected robot, since each of these parameters determines for itself. And on the pages of the forex portal, the methods of optimizing the automatic telephone exchange have been described more than once. It is probably not worth mentioning the fact that it is highly desirable that you understand the principles of work. automatic strategy and its algorithms. Of course, the best and most secure would be the purchase and installation of a forex advisor with online monitoring. Thus, testing the robot will be completely optional, but rather just an opportunity to once again convince yourself of the correctness of the decision. However, if you decide to download an advisor for free from any resource (including ours), be sure to optimize it and test it in a special program of your terminal, the metatrader.
First, you need to download the archive of the quotes of the tested currency instrument to your terminal. This must be done for the simple reason that the display of quotes in your terminal is usually present only from the moment you first install or update the program. And in cases where you are constantly working with the tool. Actually, in any case, it is better to download the archive of quotes so that you do not worry afterwards. By the way, we advise you to use our guide for testing forex advisors in MT4, as we have repeatedly encountered the wrong idea of how exactly this should be done. For example, on many sites the most common error in testing was encountered: downloading the timeframe in accordance with the recommended advisor. That is, if your trading robot was created for the M15 time interval, then the quotes with the corresponding TF were also loaded. This is fundamentally wrong! It is always necessary to load only one-minute charts, since the construction of any timeframe begins with them. You may ask, what does such a mistake threaten you with? Yes, at least that Expert Advisor testing program will not be able to determine the course of the price inside the 15-minute candlestick, which means that it will most likely not be able to rearrange the stop order to a buzubytok and, accordingly, show a lower profitability. In general, internal price fluctuations in a candle are extremely important and the lack of this information can significantly affect the overall testing results. So let's get closer to the essence of testing itself. In order to download the quotes of a currency instrument, select the column "service" and "archive of quotes" (see the picture), then select the M1 timeframe and the currency instrument itself.
The screenshots from the terminal are taken from publicly available sources, here we have a slightly incorrect example (sampling of the M15 time interval), but the essence should be clear. Then we just download the archive and wait for the operation to complete. When the archive of quotes is successfully finished (by the way, you can download quotes from one broker, and then upload them to your terminal; Dukascopy is considered the best for today, tests on its quotes give up to 99% accuracy), install the forex advisor in the terminal, if you have not done this before.
So, we have downloaded the archive of quotes and installed the ATC, now we only have to test the Expert Advisor in the Metatrader 4 (MT4) terminal. To do this, click on a special button with a magnifying glass in the upper navigation of the terminal, called the strategy tester. Or use the following combination: view - strategy tester. After that, a special tester window will appear at the bottom of MT4, the functionality of which allows you to select an advisor, a currency instrument, a time interval for testing, a testing period (the date "from and to" is selected). The settings of the advisor are also configured from the menu of the tester program: lot size, starting deposit, stop order levels and trade targets. In general, any parameter inherent in the capabilities of the tested robot.
Above you can see the view of the program for testing the robot in MT4, it is extremely simple and intuitive. We think that it makes no sense to delve into its use. However, it is worth noting several important factors: be sure to choose a model in the graph: every tick and in case of high drawdowns, stop the test ahead of schedule, optimizing the EA parameters. If the simulation accuracy in the end is more than 85%, the testing can be considered successful. We wish you every success in your search for the best forex advisor.
We offer you an updated version of our website visitors. testing advisors with 99% quality, which is free and became available for use in new builds (from 765 and higher) of the MetaTrader 4 terminal.
You can assess the reliability and profitability of the advisor you are using before it has time to drain your deposit by carrying out its high-quality testing. On the site, we have already written about the possibilities of free and paid testing of Forex strategies and Expert Advisors. One of such possibilities was checking the advisor with the help of. However, if you go to the site of this program, you will notice that its developer "closed the shop", and now the owners of terminal versions 765 and higher can use it only after payment (clickable image):
Rice. 1. Available functions of the paid and free version of TickStory.For those who do not want to spend money, we offer a new, no less high-quality method of testing Forex advisors, which requires only yours, two free applications and a little time for the general setup of the testing system.
You may ask: Was it possible to conduct testing with 99% quality in the tester before? trading platform? ... The answer is no. The fact is that MetaTrader did not provide and still does not provide access to tick quotes, due to which such a high level of quality is achieved. However, new builds allow the use of third-party tick data in the process of testing Forex advisors, which the trader must first convert into the desired format.
Preparatory work.
In order to test Forex advisors with 99% quality, you need to download the terminal itself from the site and install it. Let it be used only for tests. Then it should be created.
The next step is to download the StrategyQuant Tick Data Downloader for downloading tick data from the DucasCopy website. You can download it from this page. To do this, click on the green Download button at the end of the page, then in the form provided, enter the name and email address where the link to download the program will be sent. Carry out a standard installation of the program.
And finally, download CSV2FXT, which you need to convert files with tick data into files that the terminal will recognize:
Download csv2fxt.rar (Downloads: 690)
Copy the script files to the corresponding folders of the MetaTrader 4 terminal.
Settings.
StrategyQuant Tick Data Downloader has many settings, but not all of them are necessary for our purposes. Therefore, we will dwell only on the functions we need:
- - click on the Configure button and check the box opposite Automatic export to CSV;
- - if necessary, in the Change timezone item, configure the received data (the screen is clickable):
Rice. 2. Setting up the Tick Downloader for downloading quotes.
The program will output two files of quotes in CSV format: in one file the data will be presented taking into account the specified time shift, and in the other - without the shift, which is recommended to use.
To download quotes, you must specify pairs and date ranges (click to enlarge):
Rice. 3. Specify the required time period for downloading quotes.
Then we indicate the path where the file with quotes will be saved. By default, the suggested path is to the folder where StrategyQuant Tick Data Downloader is installed, the \ tickdata \ subfolder. You can create a new one or select another folder, and click on the Save button to save the file:
Rice. 4. Select the path to save the quotes file.
Downloading will start after clicking on the Start Download button. After downloading, you will find 2 files in the folder:
Rice. 5. Files with downloaded tick quotes.
Why two - wrote about it above. Keeping in mind that it is better to use a file with quotes without a time shift, after downloading the first file, you can stop the program and delete the second file.
Conversion of tick history.
After downloading the quotes file, transfer it to the data directory, to the folder trading terminal\ MQL4 \ Files \. You can change the name of the file and leave only the name of the pair in it, for example - EURUSD. Then we open the platform, the chart of the instrument with the required time frame, for which the quotes were downloaded, run the script:
Rice. 6. Window of the CVS2fxt script settings.For the script to work correctly, you only need to change some of its parameters, but to get acquainted with this utility, we will describe each parameter:
- - CVS2FXT version - script version;
- - CVS filename - name of the data file. In the case when it coincides with the name, then there is no need to write something here. Otherwise, fill in this field (for example, write EURUSD.csv);
- - Create HST - create HST files, set True here. The history of quotes in MT4 is stored in files with the .hst extension, and the built-in tester changes the format to .fxt;
- - All spreads and comissions in pips - total amount spreads and commissions c. Can be set to 0;
- - Spread -. You can also specify a value of 0 here;
- - Date range info - date range;
- - Start Date / End Date - data limitation for conversion by the first and last date. If these dates are not specified, then all data from the file will be converted;
- - Use real (variable spread) - if the value is True, the real spread will be used, but we indicate the spread in the tester, so we set the value to False;
- - Spread padding - set the value to 0, since the broker's additional spread is indicated here, we do not take it into account;
- - Minimum spread - also set the value to 0, this is the size of the minimum spread in the file;
- - Comission info - information about commissions;
- - Comission in pips - commission size in pips, indicate 0;
- - Commission in accoun currency - the size of the commission specified in, leave 0;
- - Leverage -, set Automatic;
- - FXT GMT and DST info - information about GMT offset and daylight saving time settings in the .fxt file;
- - FXT GMT offset - time offset from GMT time in .fxt files;
- - FXT DST setting - allows you to select daylight saving time in .fxt files, taking into account the broker;
- - CSV GMT and DST info - information about the time shift settings from summer time and GMT time in the .fxt file;
- - CSV GMT offset - it is recommended to set the Autodetect value, this parameter is responsible for the time offset from GMT in the .csv file;
- - CSV DST setting - daylight saving time settings in the .csv file. The Autodetect value is also recommended;
- - Remove duplicate ticks - removes duplicate tick data;
- - Create M1 FXT, Create M5 FXT, Create M15 FXT, Create M30 FXT, Create H1 FXT, Create H4 FXT, Create D1 FXT, Create W1 FXT, Create MN FXT - using these parameters, you can create several .fxt files at the same time for different time periods. By default, only one file will be created for the time frame on which the script is running;
- - Time shift info - use of time shift;
- - Time shift - use or not use time shift. If set to True for this parameter in the .fxt file, the dates will be overwritten 28 years ago. This is done so that advisors who try to hide bad results of work by blocking their work in certain periods, could not deceive the trader. He will be able to compare tests for shifted and regular quotes, and if the results are different, then you should carefully consider the selected Expert Advisor;
- - Price multiplication factor - the number by which all quotes are multiplied after conversion. For standard quotes, this value should be equal to one. But if you downloaded quotes for CFDs, metals, indices, then they can be presented in a form other than normal quotes, for example, multiplied by a certain number.
As soon as all the parameters are set, click on the OK button. The program will ask for permission to transfer and overwrite files, which must be given to it. After that, the terminal will need to be restarted.
Now you can start testing Forex EAs with 99% quality by specifying in the strategy tester the pair for which the test is being made, the time frame and the spread. We hope this method will be convenient for you and will improve the efficiency of using automated robots - advisors!
Today we will share the testing methodology and tell you about some very important nuances when testing Expert Advisors in MT4.
Terminal preparation
The first thing you need is a separate terminal set up specifically for tests.
Alpari can be used. Open a demo account and download the terminal. It should be installed in a directory where there is a minimum 30-50 GB free, more is possible. The point is that tick quotes take up a lot of space.
After installation, we log in to the demo account, and then disconnect the terminal from the network. To do this, click Ctrl + O, and then everything is as in the picture:
If we specify this server, username and password, the terminal will not be able to connect to this proxy server, therefore, it will be "offline".
The terminal must be disconnected from the network so that during testing it does not accidentally overwrite the high-quality quotes that we have uploaded into it.
With the terminal finished, it's time to deal with quotes.
Quotes and simulation quality 99%
The higher the quality of the simulation, the more the results of the tests obtained will be similar to real trading.
The MT4 terminal does not know how to store tick quotes, so the maximum that you can achieve under normal conditions is 90%
To achieve the best quality, we will use tick quotes from the Dukascopy broker. And the TickStory Lite program will help us download them.
What tick quotes give
They almost completely mimic the real market except for slippage and floating spreads. The results obtained in the strategy tester will be as close to real ones as possible.
So, we installed TickStory Lite and tested the program's functionality.
Now, regarding the correct testing of Expert Advisors. When exporting quotes from TickStory Lite to MT4, in the export settings you should remove spread and swap:
The spread creates an extra load on the deposit during testing, thus, even a profitable strategy can gravitate downward. If you really want to uncover the potential of a strategy, you should test it first without spread or swap. This way we know the pure effectiveness of the strategy without further ado. And only then, when the strategy is fully studied, you can connect spread and swap. This is the only and correct way to search for profitable patterns, since many of them are not able to cover the size of the spread.
When the quotes are exported, you should run any Expert Advisor and check the quality of the simulation. If it is 99%, then everything is correct, you can go further.
Not all strategies lend themselves to testing, but if you set a goal, you can test anything.
Those who already have an advisor can skip this section and go directly to testing.
Those who do not have it can use any free one or download here.
You don't have to be a programmer to write your own Expert Advisor. For example, you can use the Etasoft Forex Generator program, which easily creates frameworks for all Expert Advisors. It's old, but it still works great.
When developing advisors, it is important to set the right goals for yourself:
- Wrong target: " I want an Expert Advisor based on this indicator + divergence, so that it works stably with a plus. "
- Correct goal: " I want to know if this indicator works, and to understand whether it can be applied in practice ".
The difference is that in the first case, traders usually go in cycles and try to squeeze the desired profitability out of the EA. But that doesn't happen.
Let's assume that the Expert Advisor already exists, let's move on to testing it.
Before starting any tests, you can run this Expert Advisor, which opens trades in a random direction. If its results revolve around zero, then the terminal and quotes are set up normally and the spread is disabled.
You can start testing the Expert Advisor itself.
Step 1. If you have an Expert Advisor that trades by any indicator, install this indicator on a prepared chart template.
This is necessary in order to further check the correctness of the advisor's work.
Step 2. Configure the Expert Advisor, specify the testing period, date range, etc.:
Step 3. Start the first test by pressing the "Start" button. Some deals should appear in the "Chart" tab. If there are no deals, then there are some problems with the advisor, for more details see the "Journal" tab. If everything is fine in the journal, but there are still no deals, then you have set unrealistic criteria for entering a deal.
Step 4. After completing the test, click on the "Open chart" button. If you have previously prepared a template, then you will see a chart with an indicator that the advisor trades on. Be sure to check the correctness of the advisor's inputs.
Step 5. If the advisor works correctly, you can start the selection optimal settings... For example, the size of SL, TP, lot size, criteria for entering a trade, etc. We conduct tests and select the optimal parameters.
Step 6. Testing other timeframes and currency pairs, we draw conclusions from the received data
Evaluation of the results
The most important point that everyone usually forgets about.
Go to the tab "Results", RMB for any deal → Save as father T.
As a result, you will get the following report:
We will not analyze all the parameters, let's talk about the most important ones.
Profitability shows the ratio of total profit and total loss. The more profitability, the less false entries it generates trading system... Profitability over 1.10 can be considered normal.
Expected payoff- the average profit per trade.
If the EA uses a fixed lot of 0.1 lot, the expected payoff will coincide with the average number of points received in each trade. This is very convenient when comparing whether the advisor will be able to cover at least the size of the spread.
In the picture above, the EA brings 4.6 pips on each trade, which is clearly more than the spread.
Maximum drawdown- the maximum percentage of loss of the deposit for the entire testing period. The generally accepted maximum drawdown is 20%, try not to exceed this threshold.
Percentage of profitable trades- be sure to compare this parameter with the average profitable and unprofitable deal... Using this data and a formula, you can calculate the effectiveness of your advisor.
In general, the test results should confirm or disprove your theories. If the Expert Advisor or the pattern is not working, go to the next one, and make a note for yourself, for example, that RSI does not work. And so on ad infinitum, until you create a profitable trading system.