By continuing to use our website you agree that cookies are used to improve the user experience (e.g. to saving settings). More info. That's Fine
Please support us by disabling the ad blocker for our website. Thank you! I will

How we backtest an Expert Advisor

Almost all expert advisors (EA) we backtest are based on the MetaTrader platform.
Most of them are available for MetaTrader 4, a quite old software.

The backtest abilities of MetaTrader 4 are limited. Many things like good tick data, real spread backtests or slippage simulations are not available.

Fortunately, a developer called "Birt" has developed a software package called Tick Data Suite (TDS) to fill this gap.

TDS allows you to download tick data from different data sources.

Sadly, the market lacks publicly available tick data with a history of more than 10 years and a good quality. One of the best data sources available is Dukascopy, which we mainly use.

Is a backtest accurate, using MetaTrader 4 and TDS?

To answer this question, you need to know that no backtest is perfect. The reality will always produce different results. There are a few limitation using backtests:

  • Different price feeds: Every broker has its own price feed with different spreads (= tick data). Different tick data can produce very different results, especially with scalper EAs.
  • Slippage: TDS can simulate slippage, which is pretty good. But the reality is that you never know when slippage (positive or negative) will occur. Slippage can have different reasons. A slow order execution or insufficient liquidity. The higher the lot size you want to trade and the faster the markets move, the more likely you are to get slippage. TDS in its current stage can only simulate one type of slippage.
  • Bad tick data: Your backtests can only be as good as the tick data you use for the backtest. Most tick data contain gaps and therefore do not achieve a tick data quality of more than 99%. 
  • Swaps: TDS offers the possibility to include swaps in back tests, but the available tick data does not include the historical swaps. Currently positive swaps could be negative in the past. Performing a backtest with fixed swap rates can lead to incorrect results. In addition, MT4 always calculates the swap at 00:00, regardless of the time zone selected in the TDS settings.
  • Single currency pair limitation: Some EAs are working simultaneous on more than one currency pair. MetaTrader 4 does not provide the possibility to run a backtest that opens positions on more than one selected currency pair.

 

Isn't a backtest useless with such limitations?

Yes and no. Yes, a backtest is not perfect and you should be aware of this. Most backtests will show a "too good to be true" picture.Be aware of the fact that it is relative easy to get good backtest results if you optimize your EA to exactly this data.

But besides these limitations, backtesting can help you in many ways. It can give you an idea how the EA works and how much risk is involved.

If an EA is not able to produce positive backtests, there will be a high chance that it could fail on a real account too. Keep in mind that even the best backtest is no guarantee that an EA will be profitable on a real account.
 

How we backtest an EA

We mainly use the following set up:

  • MetaTrader 4
  • TDS
  • Dukascopy and sometimes 1-2 additional tick data sources
  • Fixed lot sizes of 0.1 lots (if the EA offers this option)
  • Execution delay slippage of 200-300ms: TDS allows us to use only one slippage type and an execution delay is very important, especially for EAs that trade during fast market periods or that hold position for a short duration. 
  • $5 commission per lot, round trip
  • No swaps, because there are no historical swaps available. Using the current swap for all past years is inaccurate.


Why fixed lot?

Most EAs are optimized for more than one currency pair, but MetaTrader 4 can only generate one backtests per currency pair.
You can use a cumulative risk / lot calculation, if you like to know the highest drawdown for a single currency pair.

However, if you want to know the highest drawdown for a portfolio of more than one backtest, the only way to calculate it is using fixed lots backtests.

In case of fixed lot backtests, the maximum drawdown of a portfolio has to be calculated based on the $ based drawdown.

For example this portfolio:

The maximum drawdown is $309.51, while the backtests are based on a deposit of $1000. In case the max. percental drawdown would be 30.95%. 

Shifting the data by 28 years

For some EAs we add backtests where the exact same tick data is shifted to 28 years earlier dates. Why do we do this? 

A 28-year shift in the data results in the exact same distribution of the weekdays over the year because 28 years contain 7 leap years. For example, if July 1 is a Monday in 2019, then it was also a Monday in 1991. An EA that does not use any special date filters (for example a news filter), should in theory have the exact same trades if the same tick data is shifted by 28 years. If this is not the case, one reason could be that the EA filtered out losing days in the backtests. But there might also be other explanations, so one should not be too quick to judge. We just show the results and if there is a large difference, one should be cautious. 


All blog posts (7)


Recent blog posts

Useful forex websites

There are dozens of useful forex websites out there. We want to share some of them with you.


How to install an EA from the mql market?

A tutorial for beginners that do not have much experience with the MetaTrader 4 platform yet.


9 tips: How to be successful using expert advisors

Check out our 9 top tips on how to be successful using expert advisors (EAs) and why most forex trader fail using automated trading systems.


How we backtest an Expert Advisor

Find out what the limitations of backtests are and how we backtest the EAs on our website.


What is an Expert Advisor (EA)?

Expert advisors provide a unique way of trading Forex, as they help to eradicate emotion-based decisions. Find out, how an Expert advisor can help you.


How to choose a good forex broker (Part 2)

Choosing a good broker isn't easy. The following article can help you finding one of the best and top forex broker


How to choose a good forex broker (Part 1)

Choosing a good broker isn't easy. The following article can help you finding one of the best and top forex broker



Want to start trading on a live or demo account?

Be aware that most retail traders (usually around 60-80%) lose money. Please consider whether you can afford to take the risk of losing your money.