Select Language

Backtest Expert Advisor (EA)

You can perform backtests on automated trading programs known as Expert Advisor (EA) using MetaTrader4 (MT4) / MetaTrader5 (MT5)'s Strategy Tester feature. The backtest takes historical data from MT4/MT5 and runs the Expert Advisor (EA) program within a given period to simulate its performance.

Here we will look at how to perform Expert Advisor (EA) backtests on MT4/MT5.

Switch between MT4/MT5 tabs to check the steps for each.

mt4
mt5

Step 1

Click "View" in the menu and select "Strategy Tester".

Open Strategy Tester Open Strategy Tester

Step 2

The "Settings" tab will open. Set the conditions for backtesting.

Backtest settings Backtest settings

Number

Item name

Descriptions

1

Expert Advisor

Select "Expert Advisor" from the pull-down list on the left and choose an Expert Advisor (EA) to backtest from the list on the right.

2

Symbol

Select the symbol.

3

Period

Select the period (timeframe).

4

Model

Select the historical data model to be used for backtesting.

Every tick: the most precise method, but takes time.

Control points: a very crude method based on the nearest less timeframe.

Open prices only: fastest method, but only for open prices.

5

Spread

Select the spread for backtesting. You can also type a value. If it is set to "1", it means 0.1 pips.

6

Use date

Select the period for backtesting.

7

Visual mode

Check this box to use the visual mode. When it is checked, a chart window will open at the start of the backtest, allowing you to follow the past price movements and watch the Expert Advisor (EA) make trades chronologically.

The playback speed can be adjusted using the bar next to the checkbox. Use the button next to the bar to pause the test.

8

Skip to

Click this under the visual mode to skip to a specified date. A date earlier than the testing period can't be specified.

9

Optimization

Check this box to perform optimization. Leave it unchecked as this mode is usually not used.

Step 3

To set the parameters for deposits and Expert Advisors, click "Expert properties".

Expert properties Expert properties

Step 4

On the "Testing" tab, set the initial deposit to use for backtesting. If you want to use a currency not listed in the pull-down menu, type it in the field like "JPY".

Set the initial deposit Set the initial deposit

Step 5

Click the "Inputs" tab and configure the "Value" fields for the Expert Advisor (EA)'s parameters. You don't have to edit the "Start", "Step", and "Stop" fields as they are used for the optimization feature.

Inputs Inputs
point Customize parameters

By default, the values set in the Expert Advisor (EA) program will be displayed, but you can change these accordingly. Adjustable parameters vary by Expert Advisor (EA), but in most cases, you can change the T/P, S/L, trade time, and other technical indicators used in the Expert Advisor (EA) program.

Step 6

Click "Start" to start backtesting.

Start backtesting Start backtesting

Step 7

The backtest result will be in the "Report" tab. Also, the "Graph" tab shows the change in the account balance and equity.

Backtest graph Backtest graph

The backtest result can be saved in the HTML format by right-clicking on the report and selecting "Save as Result".

Related article: Save Expert Advisor (EA) testing report

Save the backtest result Save the backtest result

Step 1

Click "View" in the menu and select "Strategy Tester". (Shortcut keys : "Ctrl"+"R")

Select Strategy Tester Select Strategy Tester

Step 2

The "Overview" tab of the Strategy Tester will open. Select "Single", "Visualize", or "Stress & Delays".

Backtest items Backtest items

Number

Item name

Descriptions

1

Single

Backtest the Expert Advisor (EA) with basic settings.

2

Visualize

Use the visual mode to perform backtesting while displaying trades on the chart.

3

Stress & Delays

Perform backtests by delaying execution and generating slippage.

point Settings can be changed midway

Default settings will change based on which icon you select. You can also change these settings individually from the "Settings" tab and recreate settings of other icons as well.

Step 3

Click the "Settings" tab and set the conditions for backtesting.

Backtest settings Backtest settings

Number

Item name

Descriptions

1

Expert

Select the Expert Advisor (EA) to backtest.

2

Symbol

Select the symbol.

3

Timeframe

Select the timeframe.

4

Date

Select the period for backtesting.
Entire history: Backtest for the entire period where historical data exists.
Last month: Backtest from one month before the current date.
Last year: Backtest from one year before the current date.
Custom period: Backtest for the specified period.

5

Delays

Select the time to delay executions.
Zero latency, ideal execution: No delay.
〇 ms (last ping to your server is 〇 ms): Delay for the transmission time with the broker server as measured by your MT5.
1-1000 ms: Delay for a selected amount of seconds among 1, 5, 10, 20, 50, 100, 500, or 1000 milliseconds.
Random delay: Delay for a random amount of seconds.
Custom delay: Delay specified in milliseconds.

6

Modelling

Select the historical data model to be used for backtesting.
Every tick: Use the ticks generated by MT5 based on 1-minute OHLC.
Every tick based on real ticks: Use the broker's real ticks for the logged-in account.
1 minute OHLC: Use the 1-minute Open, High, Low, and Close prices.
Open prices only: Use the open prices of the selected timeframe.
Math calculations: Select this option if you want to use the Strategy Tester for calculations. This is not for backtesting.

7

Deposit

Select the initial account balance and currency.

8

Leverage

Select the leverage.

9

Optimization

Select the optimization method. Leave the default "Disabled" as it is not used for normal backtesting.

10

Visual mode with the display of charts, indicators, and trades

Check this box if you use the visual mode.

When it is checked, a chart window will open at the start of the backtest, allowing you to follow the past price movements and watch the Expert Advisor (EA) make trades chronologically.

point Historical data model affects accuracy and efficiency

If you choose "Every tick" or "Every tick based on real ticks", the accuracy of the backtest will increase because these two contain the most amount of data. If you wish to perform a quick backtest, choose "1 minute OHLC" or "Open prices only" which contain fewer data. If you wish to analyze the Expert Advisor (EA) performance thoroughly, you should use "Every tick" or "Every tick based on real ticks".

Step 4

Click the "Inputs" tab and set the values for the Expert Advisor (EA) parameters.

Expert Advisor (EA) parameters Expert Advisor (EA) parameters
point Customize parameters

By default, the values set in the Expert Advisor (EA) program will be displayed, but you can change these accordingly. Adjustable parameters vary by Expert Advisor (EA), but in most cases, you can change the T/P, S/L, trade time, and other technical indicators used in the Expert Advisor (EA) program.

Step 5

Click "Start" to start backtesting.

Start backtest Start backtest

Step 6

The backtest result will be in the "Backtest" tab. Also, the "Graph" tab shows the change in the account balance and equity, as the blue and green lines respectively.

Backtest result Backtest result

The backtest result can be saved in two formats, "Open XML" and "HTML".

Related article: Save Expert Advisor (EA) testing report


Date

Created

 : 2022.10.28

Update

Last updated

 : 2024.08.28

Takayoshi Nakamaru

Manual production consultant, MBA

arrow
Takayoshi Nakamaru

Nakamaru is a manual production consultant at FINTECS, a company that specializes in creating manuals for their clients.
With a wide range of experience from fintech to entertainment, he presents what user-friendly manuals should be like.
He works with numerous large corporations as an external manual production project manager.

【Business information】
http://www.fintecs.co.jp/profile/

Supervisor

Akira Takagi

Systems engineer, MetaTrader administrator

arrow
Akira Takagi

After graduating from Computer Science at the Uninove, Brazil, in 2014, he has worked on various systems development projects.
He participated as a developer in the launch of forex services in 2019. Since then, he has also been involved in the development of MetaTrader plugins and APIs. He is certified by MetaQuotes as a MetaTrader5 Administrator and active in consulting and advisory as well.

Was this article helpful?

We hope you find this article useful. Any comments or suggestions will be greatly appreciated.  
We are also looking for writers with extensive experience in forex and crypto to join us.

please contact us at [email protected].

Thank you for your feedback.
Thank you for your feedback.

Disclaimer:arw

All information and content provided on this website is provided for informational purposes only and is not intended to solicit any investment. Although all efforts are made in order to ensure that the information is correct, no guarantee is provided for the accuracy of any content on this website. Any decision made shall be the responsibility of the investor and Myforex does not take any responsibility whatsoever regarding the use of any information provided herein.

The content provided on this website belongs to Myforex and, where stated, the relevant licensors. All rights are reserved by Myforex and the relevant licensors, and no content of this website, whether in full or in part, shall be copied or displayed elsewhere without the explicit written permission of the relevant copyright holder. If you wish to use any part of the content provided on this website, please ensure that you contact Myforex.

  • Facebook
  • Twitter
  • LINE

Myforex uses cookies to improve the convenience and functionality of this website. This website may include cookies not only by us but also by third parties (advertisers, log analysts, etc.) for the purpose of tracking the activities of users. Cookie policy

I agree
share
Share
Cancel