The Strategy Tester allows you to test and optimize trading strategies (Expert Advisors) before using them for live trading. During testing, an Expert Advisor with initial parameters is once run on history data. During optimization, a trading strategy is run several times with different sets of parameters which allows selecting the most appropriate combination thereof.
The Strategy Tester is a multi-currency tool, which allows you to test and optimize strategies trading multiple financial instruments. The tester automatically processes information of all symbols that are used in the trading strategy, so you do not need to manually specify the list of symbols for testing/optimization.
The Strategy Tester is multi-threaded, thus allowing to use all available computer resources. Testing and optimization are carried out using special computing agents that are installed as services on the user's computer. Agents work independently and allow parallel processing of optimization passes.
An unlimited number of remote agents can be connected to the Strategy Tester. In addition, the Strategy Tester can access the MQL5 Cloud Network. It brings together thousands of agents around the world, and this computational power is available to any user of the trading platform.
In addition to Expert Advisor testing and optimization, you can use the Strategy Tester to test the operation of custom indicators in the visual mode. This feature allows to easily test the operation of demo versions of indicators downloaded from the Market.
Testing of an Expert Advisor is its single run with fixed parameters using historical price data. It allows you to test how the strategy works before you use it on a real market.
Watch the video: How to test Expert Advisors and Indicators before purchase
Watch the video to learn how to test a trading robot before you purchase it from the Market. Every product on the Market is provided with a free demo version, which can be tested in the Strategy Tester. Please watch the video for further details.
After tester launch, instead of multiple settings the user sees a list of standard tasks, by selecting which they can quickly start testing. This will be especially useful for users without previous experience.
Some of the major strategy testing and optimization tasks are presented in the start page. In addition, one of the previously performed tasks can be restarted from this page. If you have run a lot of tasks and they do not fit into the start page, use the search bar. You can find a test by any parameter: program name, symbol, timeframe, modeling mode, etc.
After selecting a task, the user proceeds to further testing parameters setup: selection of an Expert Advisor, symbol, testing period, etc. All irrelevant parameters which are not required for the selected tasks are hidden from the setup page. For example, if mathematical calculations are selected, only two parameters should be specified: selection of a program to be tested and the optimization mode. Testing period, delay and tick generation settings will be hidden.
All available testing options will be explained below.
Click " Test" in the context menu of an Expert Advisor in the Navigator window.
After that the Expert Advisor is selected in the Strategy Tester.
The Strategy Tester allows back testing strategies that trade multiple symbols. Such trading robots are conventionally called multicurrency Expert Advisors.
The tester automatically downloads the history of required symbols from the trading platform (not from the trade server!) during the first call of the symbol data. Only the missing price history data are additionally downloaded from the trading server.
Before you start testing a multi-currency Expert Advisor, enable the symbols required for testing in the Market Watch. Open its context menu, click " Symbols" and enable the required instruments.
Before you start testing, select the financial instrument to test the trading robot operation on, the period and the mode.
Input parameters allow you to control the behavior of the Expert Advisor, adapting it to different market conditions and a specific financial instrument. For example, you can explore the Expert Advisor performance with different Stop Loss and Take Profit values, different periods of the moving average used for market analysis and decision-making, etc.
Specify a value for each input parameter.
Parameter sets. You can at any time return to the current settings of your MQL5 program by saving a set of its parameters using a context menu:
- To save the parameters as a set-file on your computer, click "Save". These files can be moved between platforms on different computers or sent to other users.
- To save parameters for future use in the current platform, click "Save Version". These saved presets will be available then in the "Load Version" sub-menu. They can be applied at any time by selecting an appropriate version from the list.
You can specify custom trading account settings during strategy testing, such as trading limits, margin settings and commissions. This option enables the simulation of different trading conditions offered by brokers.
In this section, you can set the maximum number of open orders and positions, which can simultaneously exist on the account. Additionally, you can configure sessions during which the program is not allowed to trade.
The section allows configuration of margin reserving rules and position accounting systems to be used in testing:
This section provides control over commissions charged on all trading operations:
- Commission may be single-level and multilevel, i.e. be equal regardless of the deal volume/turnover or can depend on their size.
- Commission can be charged immediately upon deal execution or at the end of a trading day/month.
- Separate commissions can be charged depending on deal direction: entry, exit or both operation types.
- Commission can be charged per lot or deal.
- Commission can be calculated in money, percentage or points.
To apply commission settings of the current trading account, enable the option "Use predefined commissions".
You can overwrite settings of the main trading instrument, for which testing/optimization is performed. Almost all specification parameters can be overwritten: volumes, trading modes, margin requirements, execution mode and other settings. Thus, if you need to check an Expert Advisor under different conditions, there is no need to create a separate custom symbol and download its history. This can be done by changing standard symbol settings.
If the symbol specification is customized, the gear icon and the symbol icon are marked with an asterisk. This shows that custom parameters are used for the current test.
To start testing, click "Start" on the "Settings" tab. The testing progress is displayed to the left.
Results of an Expert Advisor testing are displayed on tabs "Result" and "Graph".
Detailed testing results are displayed on the "Result" tab. The tab contains general testing results, including profit and the number of trades, as well as many statistical values to help assess the performance of the trading robot.
Additional charts visualize the distribution of the number and success of trading operations by hours, days and months, as well as describe the risk parameter of the trading strategy.
See the Testing report section for details.
On the "Graph" tab, you can visually determine how successfully the Expert Advisor performed on the selected instrument in the selected time interval.
The balance curve (blue line) and the equity curve (green) are shown in the main area of the tab. Dates are shown on the horizontal scale, balance/equity values are shown on the vertical scale. The bottom part of the tab features a histogram of the load on deposit, which is calculated as the ratio of margin and equity (margin/equity).
Testing Progress in the Journal
The testing progress is reflected on the "Journal". In addition, messages of the Expert Advisor are added to the Journal. In the visual testing mode, the testing progress can be viewed straight on the chart.
Testing Progress on a Chart
As soon as testing is over, you can open the chart on which the Expert Advisor was tested (selected symbol and period). Click " Open Chart" in the context menu of the "Result" tab. All the deals performed by the Expert Advisor during testing are shown on the chart. If a template named tester.tpl is available in folder /profiles/templates of the trading platform, it will be applied to the opened chart. If the template is not available, the default one is used (default.tpl).
If the tested Expert Advisor uses indicators, which run on the testing symbol and period, they are also displayed on the chart. However, if forced unloading of an indicator (the IndicatorRelease function)is implemented in the source code of the Expert Advisor, it is not displayed on the chart.
Forward testing is the repeated run of the Expert Advisor on a different time period. This feature allows you to avoid parameters fitting in certain areas of historical data.
To start the forward testing, in the Forward field of the Settings tab select the part of the total period for it:
- No — forward testing is not used;
- 1/2 — half of the specified period is used for the forward test;
- 1/3 — one third of the specified period is used for the forward test;
- 1/4 — a quarter of the specified period is used for the forward test;
- Custom — specify the forward test start day manually.
When the forward testing is enabled, the selected part is separated from the period specified in the "Date" field. The first part is the period of back testing, and the second one is the period of forward testing.
Results of the forward test are displayed on the separate tab "Forward". The start date of the forward period is marked by a vertical line on the chart.
For details about testing results please read section "Where to view the optimization results".
In the Strategy Tester of the trading platform, you can test Expert Advisors and indicators in the visual mode. This mode allows to visualize exactly how the Expert Advisor performs trade operations during backtesting. Each trade is displayed on the chart of a financial symbol.
To enable the visual test, select "Visualization" in the settings:
Set up testing options and configuration parameters, then click "Start".
Visual testing runs in a new window, which simulates a separate trading platform: it contains charts, Market Watch and the Toolbox window where you can view trading operations and the Journal.
Testing process control
To pause, speed up or slow down the testing, use the toolbar. You can also jump to a specific date of the test.
You can conveniently control the testing process via hot keys, combinations are listed next to the menu commands.
Monitoring Expert Advisor testing on a chart
The main purpose of this type of testing is the visual analysis of the Expert Advisor performance. A chart is generated in real time based on emulated historic price data. Trading robot operations are displayed on this chart.
Trading operations are displayed as icons (a Buy deal) and (a Sell deal). A dotted line is displayed between market entries and exits.
- You can change the appearance of a chart, show indicators or graphical objects on it using templates. For a template to be applied, its name must match the name of the tested Expert Advisor, for example ExpertMACD.tpl. The template should be placed in folder /profiles/templates of the trading platform.
- A list of symbols available in the chart mode is limited to the main testing symbol, as well as the symbols whose data are used by the Expert Advisor.
- The chart timeframe cannot be changed. The period selected in the settings is used for the main testing chart. Periods requested by the Expert Advisor are used for other symbols.
- To switch between symbols, use the "View — Charts" menu.
Viewing price data in Market Watch
The Market Watch window shows prices generated during testing. It is similar to the Market Watch of the trading platform, but has some specific features. To show/hide this window, use the Market Watch command in the View menu or press Ctrl+M.
The Symbols tab features the current price information of financial instruments. The list of displayed symbols is limited to the main testing symbol, as well as the symbols whose data are used by the Expert Advisor.
The Ticks tab contains a chart of prices generated during testing. The number of displayed ticks is limited to 64,000.
Viewing details of bars and indicator values in the Data Window
The data window displays information about the prices (OHLC), date and time of a bar, spread, volume and indicators. Here you can quickly find information about a particular bar and applied indicators at a selected point of the chart. The window can be enabled or disabled by clicking "Data Window" in the View menu or pressing Ctrl+D.
The upper part of the window contains the name of a financial instrument and the chart period. Information about the current cursor position on the chart is shown below. Information about indicators open in separate subwindows is shown in separate blocks.
Viewing details of trades in the Toolbox
For a detailed study of the trades performed by the Expert Advisor, use the Toolbox window. It has several tabs with the following information:
- Current open positions and pending orders
- The history of orders and deals
- The history of Expert Advisor's trade requests, including requests to modify pending orders, stop-level of positions, etc.
Information about trade operation parameters is available in sections Trade and History.
Additional details about testing are available in the Journal. It contains information about testing and actions of the Expert Advisor performed during the test.
As long as the visualizer is open, the logs of testing agents are not sent to the Strategy Tester of the trading platform. Nevertheless, they can be viewed via the trading platform using the "Local Journals of local agents" command in the context menu.
The visual testing mode allows you to monitor the behavior of indicators on historic data. This feature allows you to easily test an indicator before purchasing it from the Market. Download the free demo version and run the indicator in the Strategy Tester.
Select the type of the program "Indicators", then select the indicator and click "Start". The visualization mode is enabled automatically. The rest of the parameters are set in the same way, as during testing of trading robots.
The behavior of the indicator is shown on a chart, which is plotted based on a sequences of ticks simulated in the tester.