Advanced Guide To MetaTrader 4 - Strategy Testing And Optimization
  1. Advanced Guide To MetaTrader 4 - Introduction
  2. Advanced Guide To MetaTrader 4 - Automated Trading
  3. Advanced Guide To MetaTrader 4 - Expert Advisors
  4. Advanced Guide To MetaTrader 4 - Custom Indicators
  5. Advanced Guide To MetaTrader 4 - Scripts
  6. Advanced Guide To MetaTrader 4 - Strategy Testing And Optimization

Advanced Guide To MetaTrader 4 - Strategy Testing And Optimization

MT4 enables traders to test Expert Advisors prior to using them in a live market. This allows traders to evaluate the Expert's efficiency and to confirm that it operates as expected.

Tester Window
MT4's "Tester" is a multifunctional window where traders can test trading strategies (objective rules for trade entry, exit and management) and also optimize an Expert's parameters to find the combination of variables that will produce the most favorable results. To open the Tester window:

  • In the Main Menu > View > Strategy Tester; or
  • Press the Strategy Tester button in the Standard Toolbar; or
  • Press CTRL + R on the computer keyboard.
Any of these actions will open the Tester window at the bottom of the MT4 screen, as shown in Figure 21.

Figure 21 - The Tester window appears at the bottom of the MT4 screen.

Initially, only the Settings and Journal tabs are seen in the Tester window. The other tabs will appear as certain actions are taken; for example, the Results tab appears only after an Expert has been tested. The Tester window tabs include:
  • Settings - the settings of the testing and optimization; for example, the time period to be tested.
  • Results - the results of the trade operations performed on historical data by the Expert.
  • Graph - a graphical display of the results.
  • Report - a detailed testing report.
  • Journal - a log where all actions and internal messages of the Expert are recorded.
  • Optimization Results - data regarding every optimization pass, including inputs, profitability and drawdowns.
  • Optimization Graph - the results of the optimization shown in graph form.
Setting up Testing Parameters

To test an Expert Advisor, click on the Settings tab in the Tester window. Here, the trader will have to select the:

  • Expert Advisor - Only compiled Expert Advisors will be available for testing, and these will appear in the drop-down menu next to "Expert Advisor."
  • Expert Properties - Once the Expert has been selected, click on the "Expert properties" button to select parameters for each of the three tabs: Testing, Inputs, and Optimization.
  • Symbol and Period - The symbol is defined in the Symbol field; the timeframe is specified in the "Period" field. If there is no historical data saved for the symbol or period, the Tester will automatically download the last 512 historical bars.
  • Model - One of three methods of historical data modeling can be chosen for testing:
o Open prices only - the fastest method suitable for Expert Advisors that control bar opening.

o Control points - results are considered estimates only.

o Every tick - the most accurate method of modeling. Since this method involves a large amount of tick data, it is typically slow and can bog down the computer's operation.

  • Use Date - The historical price data on which the test will be applied; complete the From and To fields to identify a range.
  • Optimization - Check to enable the Expert parameters optimization mode; if it is disabled, the Expert will be tested but not optimized when the "Start" button is pressed.
  • Open Chart - Opens a new price chart with the symbol selected for testing. The chart will show trade entries and exits, and can be opened only after the Expert has been tested.
  • Modify Expert - Click this to open the MetaEditor and make changes to the code, if desired.
  • Start - Press the "Start" button to being testing or optimization. A progress bar will appear at the bottom of the Tester window, as shown in Figure 22.
Figure 22 -A status bar appears at the bottom of the Tester window.

SEE: Stimulate Your Skills With Simulated Trading

Setting up Optimization
MT4 can automatically create consecutive passes of the same Expert, with different inputs on the same data. Performing this optimization can help traders determine the inputs that have the most favorable results. To set up an optimization, traders must specify which variables will be optimized by clicking on the "Expert properties" button in the Tester window. This opens a new window with three tabs, as shown in Figure 23:
  • Testing - general optimization parameters
  • Inputs - inputs are variables that affect the Expert's operation. Check to include inputs in the optimization; leave unchecked to disregard during optimization. If checked, double-click in each field to specify the values for Start (initial value), Step (change interval) and Stop (final value).
  • Optimization - the tab allows traders to apply limitations during optimization. If any of the conditions is met during a separate pass of the optimization process, the optimization will be interrupted. Check to enable a limit condition, such as Profit Maximum and Consecutive Loss.
Figure 23 - Set the Testing, Inputs and Optimization parameters to perform an optimization.

After making the desired selections, click "OK" to close the window. Be sure the box next to the Optimization field on the Tester window is checked (to enable optimization), and click "Start" to begin the optimization. Optimizations take varying amounts of time depending on the type of data on which the optimization is performed and the complexity of the inputs. In general, multi-variable optimizations - those that test multiple levels of multiple variables - take the longest.

Optimization Results

The Optimization Results tab in the Tester window contains a final report of each pass of the optimization. All data are presented in a table with the following fields, shown in Figure 24:

  • Pass - pass number.
  • Profit - net profit (gross profit minus gross loss).
  • Total Trades - total number of trades generated.
  • Profit Factor - ratio between the total profit and total loss. Values less than one indicate a losing system.
  • Expected Payoff - mathematical expectation of winning.
  • Drawdown $ - maximum drawdown in relation to the initial deposit.
  • Drawdown % - maximum drawdown in terms of percentage.
  • Inputs - dynamic values of inputs during each pass.
Figure 24 - Optimization results by pass; the inputs used to create the results of each pass appear in the Inputs column on the far right.

Click any header (such as Profit) to sort data by that field. Right-click the Optimization Results and select "Save as Report" to save a copy of the results.

SEE: Calculating Profits And Losses Of Your Currency Trades

Automated trading and strategy testing/optimization are advanced features of the MetaTrader 4 platform. Automated trading is popular because it removes some of the emotion from trading, helps traders avoid costly order-entry mistakes, and responds quickly to changing market conditions. The ability to test and optimize a trading idea (Expert Advisor) prior to placing it in a live market with real money is an invaluable step in the development of a profitable trading system.

  1. Advanced Guide To MetaTrader 4 - Introduction
  2. Advanced Guide To MetaTrader 4 - Automated Trading
  3. Advanced Guide To MetaTrader 4 - Expert Advisors
  4. Advanced Guide To MetaTrader 4 - Custom Indicators
  5. Advanced Guide To MetaTrader 4 - Scripts
  6. Advanced Guide To MetaTrader 4 - Strategy Testing And Optimization
  1. Paper Trade

    Using simulated trading to practice buying and selling securities ...
  2. Prime Of Prime - PoP

    A brokerage that provides service to traders (especially Forex ...
  3. Digital Currency Exchanger - DCE

    A market maker who exchanges legal tender for electronic currency, ...
  4. Bid And Asked

    A two-way price quotation that indicates the best price at which ...
  5. No Dealing Desk

    A way of forex trading that provides immediate access to the ...
  6. Micro Account

    A forex trade made up of contracts for 1,000 units of currency. ...
  1. What happens if a software glitch fails to execute the strike price I set?

    If you've ever suffered the frustrating experience of having an order not filled or had a strike price fail to execute because ... Read Full Answer >>
  2. Will technology ever disrupt the role of the custodian bank?

    Custodian banks, along with other financial institutions that hold custodian accounts, are likely to be disrupted but not ... Read Full Answer >>
  3. How do I close a long position in forex?

    Closing a long position in forex trading depends on whether you are using a broker operating under U.S. trading regulations. In ... Read Full Answer >>
  4. What is the difference between business intelligence and competitive intelligence?

    Competitive intelligence is the act of understanding a company's industry and industry rivals so the company can make better ... Read Full Answer >>
  5. Should I attempt to trade futures myself using software, or is this better left in ...

    The question of whether to do your own futures trading or opt for a managed account that a professional trades on your behalf ... Read Full Answer >>
  6. How do I place a limit order online?

    Nearly all trading orders can be placed online through a trading platform usually provided by a broker. A limit order is ... Read Full Answer >>

You May Also Like

Hot Definitions
  1. Real Estate Investment Trust - REIT

    A REIT is a type of security that invests in real estate through property or mortgages and often trades on major exchanges ...
  2. Section 1231 Property

    A tax term relating to depreciable business property that has been held for over a year. Section 1231 property includes buildings, ...
  3. Term Deposit

    A deposit held at a financial institution that has a fixed term, and guarantees return of principal.
  4. Zero-Sum Game

    A situation in which one person’s gain is equivalent to another’s loss, so that the net change in wealth or benefit is zero. ...
  5. Capitalization Rate

    The rate of return on a real estate investment property based on the income that the property is expected to generate.
  6. Gross Profit

    A company's total revenue (equivalent to total sales) minus the cost of goods sold. Gross profit is the profit a company ...
Trading Center
You are using adblocking software

Want access to all of Investopedia? Add us to your “whitelist”
so you'll never miss a feature!