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

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

Conclusion
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.


Related Articles
  1. Trading

    Advanced Guide To NinjaTrader: Strategy Analyzer

    The NinjaTrader Strategy Analyzer allows traders to run historical analysis on NinjaScript-based automated trading strategies. To open the Strategy Analyzer, within the NinjaTrader Control Center ...
  2. Trading

    Beginner's Guide To MetaTrader 4: Setting up a Trade

    By Jean Folger Connecting to Data Centers/Live Accounts and Historical DataOnce MetaTrader 4 has been launched, an account opened (even a demo account), and the connection confirmed, traders ...
  3. Trading

    How To Place A Trade With MetaTrader 4 - Placing An Order

    Opening the Order Window The MetaTrader 4 Order window is used to place trades. The Order window can be opened using any of the following methods (see Figure 2): 1. Right-click on a currency ...
  4. Trading

    Trading Systems: Troubleshooting And Optimization

    Even after successfully designing and constructing a working trading system, a trader may find that his or her system is imperfect. There may be some problems, such as an event that keeps generating ...
  5. Trading

    How To Apply Relative Strength Index With MetaTrader 4: Customizing RSI

    Traders have the option to change inputs or use the default settings. After the indicator has been selected, a RSIwindow will automatically appear. The window will have three tabs: Parameters ...
  6. Trading

    Beginner's Guide To ScottradeELITE Online Trading - Trading

    Traders and investors can use the ScottradeELITE platform to place orders for stocks, ETFs and options. Placing a Stock or ETF OrderThe ScottradeELITE Order Entry window is where orders to ...
  7. Professionals

    Dream Jobs That Are Attainable

    As Confucius once said, "Choose a job you love, and you will never have to work a day in your life."
  8. Trading

    Using Trading Indicators Effectively

    Select multiple indicators, avoid information overload and optimize indicators to effectively use technical analysis tools.
  9. Trading

    Beginner's Guide To MultiCharts Trading Platform: Charts And Settings

    MultiCharts supports many different data providers, and more are added with each new release of the platform. Traders can use one, two or several data sources at the same time. Each data vendor ...
  10. Trading

    How To Apply Moving Averages With MetaTrader 4: Editing The MA

    Pressing CTRL + I on the keyboard will open a window that lists all indicators on the active chart, shown in Figure 8. To change the inputs for the MA (or any other indicator), highlight the ...
Trading Center