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

Trading Heroes

Forex Trading Education

  • Articles
  • Products
  • 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 / Trading Software Tutorials / How to Use Strategy Tester in MT5 to Backtest EAs

Last updated: August 11, 2022
By Hugh Kimura

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.

RELATED: Get RSI alerts for MT4, never miss another trade

RELATED: Get RSI overbought/oversold alerts on MT5.

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.

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.

Related Articles

  • RSI divergence exampleRSI Trading Strategy Results: 3 RSI Strategies Backtested
  • The Beginner's Guide to Forex Forward TestingThe Beginner's Forex Forward Testing Guide
  • MT4i Trading JournalHow to Track Forex Trading Strategies in MT4i
  • MT4 chart templateHow to Setup a Clean Chart Template in MetaTrader 4
  • Outside Bar Trading StrategyBacktesting Results: Trending Outside Bar (TOB) on Major Pairs Daily Chart
  • Manual backtesting software shootoutBest Forex Backtesting Software for Manual Testing (Comparison)
  • Linux for Forex tradingHow to Run MetaTrader and Forex Tester on Linux
  • MT4 candle range indicatorCandle Pip Range Indicator for MetaTrader 4

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

About Hugh Kimura

Hi, I'm Hugh. I'm an independent trader, educator and researcher. I used to work at a hedge fund and the largest bank in Hawaii. Now I help traders optimize their trading psychology and trading strategies. Learn more about me here.

“Freedom (n.): To ask nothing. To expect nothing. To depend on nothing.”

― Ayn Rand
Nobody understand everything. Double check your assumptions. Double check others.

Primary Sidebar

Trading Guides

The Ultimate Beginner’s Guide to Forex Backtesting

How to Figure Out Your Trader Personality Profile

The Forward Testing Guide for Beginners

How to Create a Precise Trading Plan (with PDF worksheet)

Learn the weird trading method that doesn't use stop losses...

Forex Hedging Guide
FREE Guide
Download Now

Footer

Company

  • Trading Courses and Education
  • Trading Blog
  • About
  • Contact
  • Beware of Imposters

Community

  • YouTube
  • Twitter
  • Instagram
  • Facebook

Tutorials & Guides

  • Best Trading Resources
  • Free Forex Trading Course for Beginners
  • Free Backtesting Guide for Beginners
  • Trader Personality Profile
  • Best Trading Books

Articles

  • Backtesting
  • Podcast
  • Trader Life
  • Trading Psychology
  • Trading Software Tutorials
  • Trading Strategies

Trading involves risk and can result in the loss of your investment. Invest at your own risk. Past performance does not guarantee future results. All information on this site is for informational purposes only and is not trading, investment, tax or health advice. The reader bears responsibility for his/her own investment research and decisions. Seek the advice of a qualified finance professional before making any investment and do your own research to understand all risks before investing or trading. TrueLiving Media LLC and Hugh Kimura accept no liability whatsoever for any direct or consequential loss arising from any use of this information. You are 100% responsible for your losses...and gains. You are more powerful than you know, keep expanding.

 

Copyright © 2007–2023 TrueLiving Media LLC | Terms | Privacy | Risk

Learn Zen8 Forex Hedging

Hedging can be a low-stress and consistent way to trade. Enter your email and I'll send you the FREE guide. 

x