Backtesting Trading Strategies Mt4

Backtesting a strategy with MetaTrader 4 Before launching an expert advisor (EA) on a real account, it is important to test it on historical data to evaluate the performance of the trading system. MetaTrader 4 trading software features a strategy tester that can simulate performance over a defined period of time. MT4 Metatrader 4 Tutorial and Walkthrough showing the functionality and tools I believe every trader should know about. MT4 is the most common trading platform on the planet for Forex Trading. This is a walkthrough tutorial of the platform with commonly used features, Expert Adviser / EA / Robot installation. To backtest, a trading strategy is required. At minimum, a trading strategy helps to define entry and exit points for both winning and losing trades, plus a position size. In addition, a trading strategy will often provide context, such as defining if and when trades should be taken. Backtesting means testing a trading strategy or an expert advisor on historical data. MetaTrader 4 provides a very simple and fast way to do it automatically via the Strategy Tester. Make sure to test your strategy before running it on a demo or real account. Also, make sure to use quality historical data or your results will not be reliable.

  1. Backtesting In Mt4
  2. Backtesting Trading Strategies Mt4 Login
  3. Backtesting Trading Strategy Mt5
  4. Backtesting Trading Strategies Thinkorswim
  5. Backtesting Trading Strategies Mt4 Free

The great part about MetaTrader 4 is that you can create automated trading strategies called Expert Advisors (EAs) and backtest them in the built-in Strategy Tester. If a strategy works well after thorough testing, the next step is to start testing it in a demo account to see if it works in real-time market conditions.

Backtesting of automated trading strategies (Expert Advisors) is done in the MT4 Strategy Tester window. You can open it from the top menu (View - Strategy Tester) or by pressing CTRL+R. STEP 4.2 Check if Tick Data Suite 2 is loaded.

But using the Strategy Tester can be confusing when you use it for the first time. The first time I used it, I thought it was broken 🙂

So in this video, I’ll show you how to go from beginner to pro, when it comes to backtesting automated trading strategies in MetaTrader 4. Learn how to do a quick test, use the strategy optimizer and use visual mode.

If you want to learn how to use the MT5 version of Strategy Tester, you can find that tutorial here. You can also learn more about MT4 by going through these tutorials.

The text version of the video is provided below the video.

How to Setup the MT4 Strategy Tester

Before you do anything in Strategy Tester, make sure that the EA you want to test is installed. You can do this by going to: File > Open Data Folder.

SEE ALSO:Learn how to trade the 'Batman' chart pattern

From there, open this folder: MQL4 > Experts. Then drag your EA file into that folder.

You can also check to see if the EA is already installed.

Once your EA is installed, restart MT4.

Now that your EA is installed, open MT4 and click on the Strategy Tester button. This feature is NOT available in the mobile version of MT4.

The Strategy Tester window will appear at the bottom of your screen. You are now ready to do your first test of your EA.

How to do Your First Backtest in the Strategy Tester

Here is an explanation of the settings:

  • In the first box, select your EA from the dropdown list.
  • Symbol: Select the symbol that you want to backtest on.
  • Model: Use the default Every tick setting.
  • Use Date: Leave this box checked and select the From and To dates that you want to use for this test.
  • Visual mode: Leave this box unchecked for now. You can also ignore all of the settings immediately to the right of this box. They will be grayed out anyway.
  • Period: Select the timeframe chart that you want to test from the dropdown list.
  • Spread: Leave as Current.
  • Expert properties button: Click on this button to change the settings of the EA.
  • Symbol properties button: You won’t have to use this button in this tutorial.
  • Open chart: Only click this button after a test has been completed.
  • Modify expert: This is only used to modify the source code of the indicator. You won’t need this for your first test.
  • Optimization: Uncheck this box. We will get into optimization later in this post.

Once everything is setup, then click on the Start button.

Alright, this is where things may get confusing…

When you first start the test, the green bar will move from left to right. This first pass shows that the data is being loaded.

Then the green bar will reset and start moving from left to right again. This is when it’s actually testing.

You won’t see anything happening on the chart. MetaTrader 4 is testing in the background.

This is the fastest way to backtest because it doesn’t have to constantly update the chart. If you want to see the results in real-time, go to the Graph tab at the bottom of the screen. That will show you the results of every trade, as it happens.

You can also look on the Report tab to see the stats on your test.

The Results tab will show you all the trades that were taken.

Once the test is completed, you can click on the Open chart button and you will see of the trades that were taken.

This chart can help you understand if your trades are being executed as you expected.

When you double click on a trade in the Results tab, and you have the chart marked with your trades open above, the chart will jump to that trade.

That’s the fastest way to backtest your EA.

Another way to backtest is to use visual mode…

How to Use Visual Mode in Strategy Tester

Visual mode will open a chart and show you the execution of every single trade.

In order to use visual mode, simply check the Visual mode box before you click the Start button on your test.

This is what you’ll see on your chart.

Once the data loads, you’ll see the chart and the price will start changing. In order to speed up the process, move the slider next to the visual mode box all the way to the right.

Even at “full speed” the chart will move pretty slowly. So you might wonder what the benefit is to using this mode.

The primary benefit is seeing how your strategy executes in almost real-time.

When you look a the code or to a standard backtest, it can be difficult to see where the EA is making mistakes or how your settings are affecting the results.

But sometimes when you see trades executing as price moves, the issues become very clear.

Therefore, this method of testing is not geared for speed, but it’s a way to visually spot issues or optimizations.

MT4 Strategy Tester Optimizer

Now that you have a good feel for how the Strategy Tester works, you can start optimizing some of your parameters.

It would be great if there was some sort of fancy AI powered optimization algorithm, but unfortunately there isn’t.

Strategy Tester uses a very simple iterative process of trying different EA settings and showing you the results.

But that can be a good thing. When you use an AI, you don’t quite know what it’s doing in the background.

With the MT4 optimization process however, you know exactly what’s happening and identifying the best settings is a straightforward process.

To use the optimizer, click the Optimization box before you start the test.

The way that MT4 optimizes your EA settings is by allowing you to set a starting, ending, and step up value for each of your EA settings. For example, here are the settings that are available for the EA that I’m using in this example.

For each setting, you can set the following:

  • Checkbox: The parameters that are checked are the ones that will be optimized.
  • Value: The value used for normal testing.
  • Start: The start value used for optimization. This value is not actually tested.
  • Step: The increments that are used in each of the tests. In this example the step is set to 10, so the value for this input will increase by 10 on each successive test.
  • Stop: This is the final value that will be tested during optimization.
Trading

Just to clarify how this works…

If you use a starting value of 10, a step value of 10 and stop value of 30, MetaTrader 4 will test 20 and 30 only. It will not test the starting value of 10.

Also keep in mind that the more inputs you test, the longer your optimization tests will take.

Therefore, it helps to start off by testing one input at a time and use larger step intervals. Once you get an idea of what works, you can start to fine tune the settings.

After you get results that you like, be sure to do one last test with the normal Strategy Tester settings to make sure that all of your new settings work well together.

Backtesting trading strategies free

Where to Get MT4 EAs

There are many places that you can get MT4 EAs.

You can start by taking a look at the MetaTrader EA repository. This will give you a good idea of what is out there.

However, you’ll quickly see that there are a ton of EAs, but you don’t know how most of them trade. If you don’t know how they work, how will you know when they stop working?

Therefore, the best thing to do is to learn a trading strategy, test it, then create your own EA.

Even if you don’t know how to program in MT4, you can always find a programmer to create an EA for you.

I’ve used several programmers over the years and they were able to create exactly what I wanted.

To see the programmers I use, go here.

Backtesting In Mt4

The Difference Between .MQ4 and .EX4 Files

You may notice that there are two different types of EA files. This section will explain the difference.

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

The file that human programmers can read (the .mq4 file) is not very efficient in terms of processing speed, so it’s converted into a version that the computer can use efficiently (the .ex4 file).

These files are also known by the following names:

  • .ex4 = compiled, program or executable file
  • .mq4 = source code file

When you add a .mq4 file to MT4, it will automatically be converted to a .ex4 file, when you open MetaTrader 4.

If you purchase an EA on the internet, it will usually come in .ex4 format. This is because the .ex4 file hides the developer’s programming and doesn’t allow others to copy the code and resell it.

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

One final note on these files…before working with a programmer, be sure that they will give you the .mq4 (source code) version. That shouldn’t be a problem since you’re paying them.

But double check before you start working with them.

To get help with finding a MetaTrader 4 programmer, I have created this guide and list of programmers.

…and no, you cannot use MT4 files with MT5, and vice versa. This is a common question.

A Final Word of Caution

Finding an EA that will make you money while you sleep is a sexy idea. But remember that there are no free lunches in trading.

You can still screw up an EA that has been profitable in backtesting.

Here are a couple of ways that you can do that.

First of all, you have to decide when to turn on your EA.

That may sound obvious, but when an EA hits a losing streak, it can be very tempting to turn it off to stop the bleeding.

…and when you turn it off is usually when it starts working again…or so it seems.

So remember that you have to understand the statistical characteristics of your EA, so you know when it is doing something that’s out of the ordinary.

For example, if your backtesting shows that you should only have a maximum of 5 losses in a row, but your EA has currently lost 10 trades in a row, then it’s probably time to turn it off and evaluate what’s going on.

However, you certainly shouldn’t turn it off after 6 losses in a row, no matter how mentally painful that is. Based on your stats, that’s usually the time when it should start winning again.

Second, many new traders don’t test their strategy enough and jump into live trading too quickly.

Backtesting Trading Strategies Mt4 Login

There are many variables that can affect the performance of an EA in live trading, so be sure to “stress test” them all before you risk real money. Test it with a wide spread, multiple pairs and use as much historical data as possible. Six months of data is not a valid test.

The more robust your testing, the more likely your EA will work in live trading.

Mt4

Now get to work testing 🙂

Related Articles

Welcome to this video on backtesting trading strategies. The irony is that using trading backtesting software may be the absolute worst way to design trading strategies.

Learning how to backtest a trading strategy using excel, MT4 or another software program seems like a good idea at first. But it’s not. This video and article will walk you through the logic of exactly why, and what to do instead.

Was this video on backtesting trading strategies, helpful to you? Leave a message in the COMMENTS section at the bottom of this page.

PLEASE “PAY IT FORWARD” BY SHARING THIS VIDEO & ARTICLE ON FACEBOOK OR TWITTER by clicking one of the social media share buttons.


BACKTESTING TRADING STRATEGIES

Welcome to this video on backtesting trading strategies I share with you my experience with backtesting which I have done for well I did do for many many years. I don’t do it anymore and I’m going to share with you why. I have very sophisticated software very high powered computer system and I was trained in how to do this I’d find a few strategies that were viable historically.

Then what you do typically is you understand that’s curve fitting. So then you take the successful strategies and you apply them to data that is separate from the data used historically that’s called out of sample forward testing. So most of them when I took them and use them on out of sample data they failed the night. Ninety five percent of them. So then that last 5 percent which is very hard to find.

TRADING BACKTESTING SOFTWARE

Strategy

I would then start treating real live markets in current time and none of them were successful over the long period of time someone worked for a little while and then ultimately fail. So why is that. I started to wonder because I spend a lot of time on that and I was very disappointed. So I started thinking about it. I realized you know there are some real problems with the whole idea of backtesting. Here’s the first one.

You’ve seen this legal statement everywhere. Go ahead and fill in it just in your mind just fill in the the end of the sentence. Past performance is no guarantee of what you know the end of this. Most people do. We see it everywhere in websites and on documents that people send to us brokerage firm software whatever. Past performance is no guarantee of future results. This is why trading backtesting software isn’t reliable for futures profits.

HOW TO BACKTEST TRADING STRATEGIES IN MT4

So we’ve seen it everywhere. You knew that. That’s a problem. If that’s a legal statement that all these companies put on their documentation that means that that’s a very significant issue and it is in fact that many studies have been done on this Couple of a moment or in 2014 a Wall Street Journal study found that only about 14 percent of Five-Star funds retained their reading 10 years later.

Backtesting Trading Strategy Mt5

Past performance was not indicative of future results. In 2013 a Vanguard study reported that the one stars and now we’re looking at the other end The Wall Street Journal analyze the Five-Star at Vanguard study the one stars and they had the actual greatest excess returns what they call when compare it against a benchmark. So wow. What the heck’s going on. Yes I hate the opposite of what you would expect especially when most people make decisions on funds to buy based on their past performance. If this is true, then learning how to backtest trading strategies in mt4 may be futile.

HOW TO BACKTEST A TRADING STRATEGY USING EXCEL

Well to me what that indicates is there’s probably a reversion to the mean. We all know that very very few people ever outperform just the benchmark the S&P 500. And so therefore if it does outperform for a while it reverts back to the mean if it underperforms for awhile revert back to the mean. So that’s one huge problem.

Another one is that markets change over time. Back when I started trading which is decades and decades and decades ago I’d have to call my broker on a rotary phone of all things my kids don’t even know who the rotary phone is anymore. They see it in a museum. But yeah we didn’t I mean we had a black and white TV. So learning how to backtest a trading strategy using excel may not be applicable to today’s markets when using long-term historical data.

BACKTESTING TRADING STRATEGIES FREE

Backtesting Trading Strategies Thinkorswim

We certainly didn’t have computers. And so there’s no direct access. You know there were no low commissions commissions or high cost me 50 bucks to get in 50 bucks to get out decimalization wasn’t around. There was no mobile devices didn’t even have a computer. Bottom line was trading was slow slow and expensive and therefore chart patterns trended more today. People use all this technology to get in and out of the market real fast. That creates choppier chart patterns.

The patterns today are different than they were back then. Now that’s on the retail side. Now on the professional side you’ve got Elgood trading high frequency trading. It got dark pools. So the speed of what’s going on here in the retail around the professional sites even faster. And so again you get different type of chart patterns than you did in the past so. Add to that, the fact that many traders want to use backtesting trading strategies that are free and well, you get what you pay for!

FREE BACKTESTING

Okay that’s great. Now that all begs the question of all day what do we do. So the first thing to acknowledge is are no certainties in the market. Part of that reason we do free backtesting is we’re looking for some certainty as to what’s going to work in the future. And so acknowledge that there’s always risk in the market. You know back in the days of Jesse Livermore they used to call it speculation. I still prefer the term speculation to trading because it reminds me that there’s always risk in the market.

Here’s how I trade here the principles I use two things. Number one market logic and mathematical logic. So what do I mean by these. Well let’s take emerging market logic first. So I’m referring to the market profile model where the market is seen as an auction place and in an auction place you’re beating on memorabilia and so forth art whatever it might be and that that item that’s going to sell for whatever someone is willing to pay for it.

BEST WAY TO BACKTEST TRADING STRATEGIES

And that’s how the markets work too. We’ve got this global auction place essentially. But the logic of the markets not always logical. Sometimes people pay more than many people would think that a piece of art is worth because they have sentimental connection with that. And the same thing happens in the financial markets. So and we see that with bubbles. We’ve seen it in the real estate bubble recently. Before that we saw in the technology bubble before we even start with tulips. If you go back farther and of tulips of all beings and of course this is what Alan Greenspan referred to is as irrational exuberance.

The market logic is the logic of well logic in quotes of people and psychological studies have shown that people generally. Even though we don’t admit it to ourselves we generally make decisions based on emotion and justify them with logic. And so the market logic is not individual psychology but mass psychology that plays a major role in how markets move. Thus, there may be no best way to backtest trading strategies.

FREE BACKTESTING SOFTWARE

The second part of the larger equation that is the mathematical and got to include this too. Because over half of the shares in the New York Stock Exchange aren’t traded by human beings Well I should say they aren’t. The decisions the trading decisions are made by computer models and some of these don’t really affect you in your trading and you certainly can’t compete against them.

You and I cannot compete against these. You’re not going to get free backtesting software or a forex robot on the Internet for $19 that it is going to compete with Goldman Sachs or Merrill or Bank of America. So here’s what I do. I combine these two types of logic. And the bottom line is that mathematically measuring what the market participants are doing now. So again remember it’s market participants globally and I’m taking a treat now.

I need to know what’s going on in the market right at the second entering the trade. Now what happened you know six months ago 12 months ago 40 years ago I trade in the present bar by bar and manage my risk and then I use indicators to objectively and mathematically measure the money flow in and out of the market. Now that’s what we’re looking for the money.

GET MY FREE MARKET ENTRY TIMING INDICATOR

BTW, if you’re interested in the indicator that I use personally for very precise entries and exits. I’m happy to share that with you. Just send me an email at support@topdogtrading.com, and I’ll show you how to get access to that indicator.

What did you think of this tutorial on backtesting trading strategies? Enter your answer in the COMMENTS section at the bottom of this page.

Backtesting Trading Strategies Mt4 Free

PLEASE PAY IT FORWARDÂť BY SHARING THIS VIDEO & ARTICLE ON FACEBOOK OR TWITTER by clicking one of the social media share buttons.

FREE GIFT!

Also I’m giving away one of my favorite backtesting trading strategies that works in trading the markets. Just fill out the yellow form at the top of the sidebar on the right. Once you do that, I’ll personally send you an email with first video.

Those interested in the backtesting trading strategies also showed in interest in this video:
http://www.topdogtrading.com/heiken-ashi-strategy-trend-trading-unique-japanese-candlestick-chart-pattern/

Subscribe to my YouTube Channel for notifications when my newest free videos are released by clicking here:
https://www.youtube.com/user/TopDogTrading?sub_confirmation=1