• Skip to primary navigation
  • Skip to main content
  • Skip to footer
Trading Heroes

Trading Heroes

Forex Trading Education

  • Free Tutorials
  • Products
  • Resources
  • About
  • Login

How to Use Strategy Tester in MT5 to Backtest EAs

Get the step-by-step guide to using MetaTrader 5 for automated backtesting. Learn how to install EAs, adjust settings, troubleshoot problems and get reports.

Home / Forex Backtesting / How to Use Strategy Tester in MT5 to Backtest EAs

One of the best parts of MetaTrader 5 is that you can program automated trading strategies, called Expert Advisors (EAs), with the MQL5 programming language. Then you can test your strategies in the MT5 Strategy Tester.

Many traders use EAs to create fully automated trading strategies. However, EAs can also be used by discretionary traders to test new ideas, or in Incremental Automation.

Regardless if you go fully or partially automated, this post will show you how to get started with the MT5 Strategy Tester.

I'll show you how to install .ex5 and .mq5 files, how to do your first test, and how to find a MT5 programmer, if you don't know how to code.

Trading Computer

The Difference Between .MQ5 and .EX5 Files

Let's start by taking a look at the two types of files that can you can install in MT5.

There are two different types of files because there is one file that humans can read and one file that that MetaTrader can read.

SEE ALSO: Learn the RSI Divergence trading strategy that works

The file that human programmers can read (the .mq5 file) is not very efficient, so it's converted into a version that the computer can use efficiently (the .ex5 file). These files are also known by the following names:

  • .ex5 = compiled, program or executable file
  • .mq5 = source code file

When you add a .mq5 file to MT5, it will automatically be converted to a .ex5 file, when you open MT5. 

If you purchase an EA on the internet, it will usually come in .ex5 format. This is because EA developers want to protect their hard work.

The .ex5 file hides their programming and doesn't allow others to see how it works.

However, if you create an EA yourself, or you work with a programmer to create an EA from scratch, the EA will be in .mq5 format.

Before working with a programmer, be sure that they will give you the .mq5 file. Having this file will allow you to make changes to your EA in the future.

How to Install an Expert Advisor in MT5

In order to start using Strategy Tester in MetaTrader 5, open MT5, then go to: File > Open Data Folder.

You can also hit Ctrl+Shift+D on your keyboard.

Open data folder

Once the folder is open, go to: MQL5 > Experts.

Then drag your MT5 Expert Advisor into the folder. The EA can either be in .ex5 or .mq5 format.

add EA

After the file has been moved, then restart MT5. You're now ready to start testing your EA in Strategy Tester.

How to Use Strategy Tester

Set Up Your Test

When MT5 restarts, go to: View > Strategy Tester. You can also press Ctrl-R on your keyboard to open Strategy Tester.

It will appear in a window at the bottom of your screen.

Strategy Tester MT5

Here's what the settings do. They are listed in the order that they appear on the screen.

  • Expert: Select the Expert Advisor you want to test from the dropdown.
  • Symbol: Select the symbol you want to backtest.
  • Timeframe: Select the timeframe you want to backtest.
  • Dollar sign icon: Click on this icon to get details of the symbol selected.
  • Date: Select the preset date ranges.
    • Entire history
    • Last month
    • Last year
    • Custom period
  • First date dropdown: If you select Custom period, select the starting date of your test.
  • Second date dropdown: If you select Custom period, select the ending date of your test.
  • Forward: This allows you to do forward testing of your trading strategy. MT5 will split your data into 2 parts and only do optimization on the first part. Then it will test the optimized settings on the second part of the data. If you get similar results with both sets of data, then there's a higher probability that the settings are reliable and not subject to curve fitting. When forward testing is activated, you will see an additional tab that shows the forward testing results.
    • No: Forward testing not used.
    • 1/2: Half of the time period is used for the forward test.
    • 1/3: One third of the time period is used for the forward test.
    • 1/4: One fourth of the time period is used for the forward test.
    • Custom: Use the dropdown to specify the first date of the forward test.
  • Delays: You can select from several delay times to simulate delays between the time that MT5 gets a trade signal and the time the trade actually gets executed. This is useful if the connection to your broker is slow.
  • “Select delay…” Button: This can be used to include other factors that might affect profitability like slippage, non-tradable time periods, margin and commissions.
  • Modeling: You can select how ticks are generated. You can find more information on that here (it's pretty complex).
  • Deposit: Adjust your initial deposit and deposit currency.
  • Leverage: Choose the leverage you'll be using in live trading.
  • Optimization: Choose the algorithm type you want to use. There are different ways that you can optimize your EA by having MT5 run through a series of values for each of your settings until it finds the best setting. Select the inputs you would like to optimize on the Inputs tab. You can read more about optimization here.

Start Your First Test

Once you've setup the test, click the green Start button. If you've checked the “visual mode…” box, the Strategy Tester Visualization window will open and show you the backtesting trades on the chart.

SEE ALSO: This one thing is your secret trading weapon

Use the slider to increase or decrease the speed of the test. This will allow you to watch your trades and see if your EA is working as you expected.

Visualization

If you didn't check the “visual mode…” box then the test will run without seeing the trades on a chart. The best way to see the progress of your backtest is to flip to the Graph tab.

That will allow you to see live update of your equity and account balance.

Equity graph

Review Your Results

Once your test has completed, it's time to review your results. Go to the Backtest tab to see the stats on your test.

Backtest results

Where to Get MetaTrader 5 Expert Advisors

There are many ways to get a MT5 EA, but here are a few good places to start.

  • MetaTrader 5 Market
  • Trading Heroes EAs and Indicators 

There are also many other websites that sell EAs and some offer free EAs for download.

If you have an idea for a trading system or EA, you can also create your own EAs.

How to Find a MT5 Programmer

The good news is that you don't have to learn programming…if you don't want to. You simply have to explain your strategy to a programmer and have them create the EA for you. 

I created a list of Forex programmers here. Talk to them and see if any of them are a good fit.

Be sure to read the guide in the beginning to find the best programmer for you.

Learn to Program Yourself

If you would like to learn MQL5 programming, then start with the official MQL5 docs.

The best way to learn programming is to choose a simple project, then learn through trial and error.

For example, you could start off by programming a simple EA that opens a long trade when price closes above a moving average and closes the trade when price closes below the moving average.

…and the opposite for short trades.

It also helps to find free code on the internet, study how it works and make simple changes to the code. You might have to spend a couple of weeks learning how to code, but it can really pay off.

When you can code for yourself, you can test trading ideas, without paying for a developer to create the EA for you.

Conclusion

A final word of caution. Be sure to check, and double check every EA you install.

There can be bugs in the programming, which can have disastrous results. Even if you run an EA through the Strategy Tester, the results in live trading can be different.

So even if an EA does well in backtesting, always test it in a demo account for a few months before you put it into live trading. 

But all of that testing can be worth it, if you can find an EA that will help you make profits while you're away from your computer.

You Might Also Enjoy

How to Backtest in MT4
Backtesting Results: Trending Pin Bar (TPB) on $EURUSD H4 Chart
A Simple Forex Trading System Tested: Daily Pin Bars on AUDJPY

Category: Forex Backtesting Tag: Automated Forex Trading, MetaTrader 5 Tutorials

About Hugh Kimura

Hi, I'm Hugh. I'm an independent trader, educator and international speaker. I help traders develop their trading psychology and trading strategies. Learn more about me here.

Top

 

Share This Article


First posted: July 3, 2020
Last updated: July 3, 2020

Footer

Company

  • Support
  • About Trading Heroes
  • Trading Courses and Education
  • Recommended Resources
  • T-Shirts & Trading Gear
  • Charities We Support

Tutorials & Guides

  • Free Forex Trading Course for Beginners
  • Best of Trading Heroes
  • Forex Trading Blog
  • Best Trading Books
  • Forex Trading Strategies
  • What is Forex?
  • Podcast

Community

  • YouTube
  • Twitter
  • Dtube
  • Odysee
  • Flote
  • Minds
  • Private Trading Community
  • Contact
Trading involves substantial risk and there is always the potential for loss. All content on this website is for educational and informational purposes only and is not trading, investment, or medical advice. You should be aware of the risks associated with trading and seek advice from an independent certified financial adviser if you have any doubts. Some links on this page might be affiliate links, where we get a small commission if you purchase through the link. It doesn't cost you anything extra and we only recommend products that we absolutely love. This site uses cookies and using this site means that you agree to the use of cookies.

 

CFTC Rules 4.41 - Hypothetical or Simulated performance results have certain limitations. Unlike an actual performance record, simulated results do not represent actual trading. Also, because the trades have not actually been executed, the results may have under-or-over compensated for the impact, if any, of certain market factors, such as lack of liquidity. Simulated trading programs, in general, are also subject to the fact that they are designed with the benefit of hindsight. No representation is being made that any account will or is likely to achieve profit or losses similar to those shown. Testimonials appearing may not be representative of other clients or customers and is not a guarantee of future performance or success.

 

 

 

 

 

Copyright © 2007–2021 TrueLiving Media LLC | Terms | Privacy | Risk
How to choose a trading system guide

Get the FREE Guide to Picking the Best Trading Strategy For YOU

x