
Learn how to backtest a Forex EA in MT5, run historical tests, and understand the basics of automated trading bot testing.
Creating and compiling a Forex trading bot is only the beginning of automated trading. Before using an Expert Advisor in a live market, traders need to understand how it behaves when exposed to historical price movements.
Backtesting allows you to run an EA against historical data inside MetaTrader 5 (MT5). It helps you check whether the EA executes its programmed rules, how frequently it trades, and whether the testing process produces the expected results.
In the previous chapter, we explained How to install and compile a Forex trading bot in MT5. That process prepared the EA for testing.
In this article, we will continue from that point. You will learn how to open the Strategy Tester, configure the test, run your EA, and view the completed backtest results.
This tutorial focuses on completing the backtest. A separate article will explain how to interpret performance metrics, evaluate drawdown, analyse the equity curve, and make informed changes to EA settings.
Backtesting is the process of running a trading strategy or automated trading system against historical market data.
Instead of waiting for future market movements, a trader uses previously recorded price information to examine how the strategy would have behaved during a selected period.
In MT5, an Expert Advisor can be tested using the Strategy Tester. The tester processes historical data and simulates trades according to the EA's programmed logic and the selected testing conditions.
For example, suppose you have created an EA that follows a moving-average crossover strategy.
The EA is programmed to:
Backtesting allows you to examine how these rules would have been applied to historical price movements.
However, a historical test is not a prediction of future performance. Its results depend on the quality of historical data, trading costs, execution assumptions, EA programming, and the market conditions included in the test.
Before starting, make sure that:
If you have not yet created your EA, complete the previous chapter How to Install and Compile a Forex Trading Bot in MT5 before continuing.
Open MetaTrader 5 on your computer.
The Strategy Tester is the built-in tool used to test Expert Advisors against historical market data.
You can usually open it through the View menu by selecting Strategy Tester. You can also use the Strategy Tester shortcut or toolbar option if available in your MT5 installation.
Once opened, the Strategy Tester panel should appear in the terminal.

This is where you will configure the EA, select the market, choose the testing period, and start the backtest.
Inside the Strategy Tester, locate the Expert Advisor selection field.
Choose the EA you created and compiled in the previous chapter.
If your EA does not appear in the list, check the following:
If you recently created or moved the EA, refresh the Navigator or restart the terminal if necessary.
Select the correct Expert Advisor before moving to the next step.
Choosing the wrong EA can produce results that have nothing to do with the strategy you intended to test.
The trading symbol determines which market the EA will be tested against.
For example, you may select:
The correct symbol depends on the strategy.
An EA designed for EURUSD should not automatically be assumed to work in the same way on gold or another currency pair.
Different markets have different price behaviour, spreads, volatility, trading conditions, and contract specifications.
For your first backtest, select the same market for which the EA was developed.
If your broker uses a symbol suffix, such as EURUSD followed by an additional character, choose the symbol available in your terminal that matches your broker's instrument.
Choose the timeframe that corresponds to your EA's intended trading approach.
Common timeframes include:
| Timeframe | Chart Period |
|---|---|
| M1 | 1-minute chart |
| M5 | 5-minute chart |
| M15 | 15-minute chart |
| M30 | 30-minute chart |
| H1 | 1-hour chart |
| H4 | 4-hour chart |
| D1 | Daily chart |
| W1 | Weekly chart |
| MN1 | Monthly chart |
The timeframe affects how the EA processes market information and how often its trading conditions may become valid.
For example, an EA programmed to evaluate a strategy using the one-hour timeframe should generally be tested using the intended H1 configuration.
Do not choose a timeframe simply because it produces a more attractive result.
The objective is to test the strategy under the conditions for which it was designed.
The testing period determines which historical market data the Strategy Tester will use.
You can select a predefined period or specify custom dates, depending on the available MT5 interface.
For example, you might choose a historical period covering several months or years.
The appropriate period depends on the strategy's trading frequency and the market conditions you want to examine.
A short testing period may contain too few trades to provide meaningful information. A longer period may expose the EA to different market environments, although it still cannot guarantee that future conditions will behave similarly.
When selecting the period, consider whether it includes:
These conditions matter because a strategy may behave differently depending on the market environment.
The testing model determines how MT5 processes historical price information during the backtest.
Depending on the EA and the available historical data, MT5 may provide testing options such as:
The exact options and availability may depend on your terminal version, symbol, and historical data.
For strategies that depend on intrabar price movement, stop-loss execution, take-profit execution, or other price-sensitive conditions, the testing model can materially affect the results.
For example, a strategy that makes decisions during individual price movements may not be adequately represented by a simplified model that evaluates only selected price points.
For an initial test, select a model appropriate to the EA's logic.
When greater detail is needed, use a more detailed testing model supported by the available historical data.
Remember that a more detailed simulation does not automatically make a strategy profitable or eliminate differences between historical testing and live execution.

Many Expert Advisors include adjustable input parameters.
These parameters allow traders to change selected settings without modifying the underlying source code.
For example, an EA may include:
| Input Parameter | Purpose |
|---|---|
| Fast Moving Average Period | Sets the period used to calculate the faster moving average. |
| Slow Moving Average Period | Sets the period used to calculate the slower moving average. |
| Stop-Loss Distance | Defines the stop-loss distance for each trade. |
| Take-Profit Distance | Defines the take-profit distance for each trade. |
| Lot Size | Determines the trading volume of each order. |
| Maximum Spread | Sets the maximum spread allowed for trade execution. |
| Magic Number | Identifies trades opened by the Expert Advisor. |
The actual inputs depend on how the EA was programmed.
If your EA has no adjustable inputs, you may see only the default configuration.
For your first backtest, use the settings you intended to test.
Avoid changing multiple parameters simply to produce a better-looking result.
The purpose of this stage is to configure the EA for the test, not to optimise the strategy.
After selecting the EA, symbol, timeframe, historical period, testing model, and inputs, review the configuration.
Check that:
Once everything is ready, click Start in the Strategy Tester.
MT5 will begin processing the historical data.
Depending on the testing period, EA complexity, and testing model, the process may take a short time or longer.
During testing, the terminal may display progress information and other available tester details.
Allow the test to finish before reviewing the completed results.

Once the backtest has finished, the Strategy Tester provides information about the test.
The available tabs and their presentation may vary depending on your MT5 version and testing configuration.
You may see sections such as:
These sections provide different views of the test.
The Results area can show individual trade or order activity, depending on the tester configuration.
The Graph area can display the account's balance or equity development during the test.
The Overview or Backtest report can provide a summary of the test and its performance metrics.
The Journal can help you inspect tester messages and identify issues that occurred during the process.
At this stage, your goal is to confirm that the test completed and that the results are available.
Do not immediately assume that a positive result means the EA is ready for live trading.
The next article will explain how to examine these results in detail.
Before moving to detailed performance analysis, make sure the test completed as expected.
Check whether the Strategy Tester completed the selected historical period.
If the test stopped unexpectedly, investigate the tester messages before relying on the report.
Look at the available trade or order results.
If the EA did not execute any trades, the test may not provide useful information about its trading behaviour.
Possible reasons include:
A zero-trade result does not automatically mean the EA is broken. It means you need to understand why no trades occurred.
Make sure the report corresponds to the settings you intended to test.
If you accidentally selected another timeframe, symbol, or testing period, the results may not represent your strategy.
Keep a record of the EA configuration and the testing period.
This makes it easier to compare future tests and understand which settings were used.
For example, you could record:
| Test Detail | Example |
|---|---|
| Expert Advisor | Your EA name |
| Symbol | EURUSD |
| Timeframe | H1 |
| Testing Period | Selected historical dates |
| Testing Model | Selected model |
| Input Configuration | Default or recorded settings |
These are configuration details, not performance claims.
Completing a backtest gives you a report, but understanding the report requires a separate process.
In the next chapter, we will explain how to analyse Forex trading bot backtest results in MT5.
That article will examine the main performance metrics and explain what they mean for a trader.
It will cover:
The objective is to help you understand what the results reveal about the strategy, rather than simply looking at whether the final balance increased.
Backtesting a Forex trading bot in MT5 helps you examine how an Expert Advisor would have behaved under selected historical market conditions.
By configuring the Strategy Tester correctly, running the test, and viewing the completed report, you can move from creating an EA to evaluating its historical behaviour.
However, completing a backtest is only the beginning. The next step is understanding what the results mean, identifying potential weaknesses, and testing the strategy across appropriate market conditions.
Continue with the Forex Automated Trading Masterclass to learn how to analyse backtest results and evaluate an automated trading system.
The MT5 Strategy Tester is included with the MetaTrader 5 platform. However, the availability and quality of historical data may depend on your broker, symbol, and terminal configuration.
You generally do not need to place live trades to run a historical backtest. You need a properly configured MT5 terminal, an available Expert Advisor, and suitable historical data.
The EA may not have encountered its entry conditions during the selected period. Incorrect settings, symbol differences, programming issues, or unsuitable historical data may also affect trade execution.
No. Historical testing cannot guarantee future performance. Live market conditions, spreads, slippage, execution, and other factors may cause results to differ.

Written & Reviewed by
Multi-Timeframe Technical Analysis & Market Education Desk
TradeTogether Research is a market analysis team publishing structured forex, gold, and crypto technical studies, liquidity breakdowns, and trading education. Read about our research process on the About page, review our Editorial Policy, or see our Risk Disclaimer.