×

Authorised and Regulated: SCB

Speed up an MT4 Backtest

If you’re not backtesting your strategies then how do you know that your choice of parameters is effective? The process of backtesting uses historical data to reconstruct possible trades in the past, using the rules defined in your chosen strategy. This testing allows you to improve and optimize your trading strategy before applying it to real-life trading situations. The premise is that if the strategy performed well in the past, it is likely to do so in the future as well, or if it did poorly in identifying past potential trading opportunities, you can see where you need to tweak the strategy.

However, to get the most accurate results from backtesting on MetaTrader 4, you will need to customize the backtest. There are a variety of inputs for which you can set amounts, such as tick size, fractional or round lot size, position sizing, exit rules, stop loss, slippage assumptions and so on. The idea is to set the parameter according to what you are likely to use in real-life trading.

While all this might sound really exciting and good for traders, what can be frustrating is that MT4 backtesting can take time. In fact, some custom indicators seem to take much more time than others, while the same backtest might take more time in one instance than it did in the past.

How to Speed Up Backtesting on MT4

Different people might recommend different ways to speed up the backtesting process. Here are some things that have been found successful by most users:

  • Rather than using stealth stops, use fixed stop loss. Expert Advisors on MT4 take longer to calculate each tick in the stealth mode, although these calculations are important to determine the exits.
  • If the strategy you have chosen uses closed bars, ensure that indicator values are calculated only once per bar. Although this might appear obvious, many people, even veterans at backtesting, fail to ensure this.
  • If your strategy permits, use Open Only prices for backtesting. However, open only prices should not be used if:
  • Times when trades open and exit in a single candle or bar. This can occur when your take profit or stop loss is likely to be hit on an open trade’s very first bar.
  • Trade does not open on the first tick of a bar.
  • Exits occur when a bar is still open, except for take profit and stop loss.
  • Use “open prices” or “control points,” rather than tick backtests. If this does not speed things up, it is possible that there could be a bottleneck somewhere, slowing MT4 down. The two areas that could be responsible for such bottlenecks are your CPU and your storage. In order to prevent such bottlenecks, you can:
  • Switch from HDD to SDD, which has much faster load times.
  • Find out how to delete immediately or even avoid creating unnecessary objects.
  • Unless it is an intraday strategy, avoid processing ticks (or anything else for that matter) that are not required.
  • For longer tests, try the non-visual mode. All the visual mode does is to allow you to see whether the code is performing as expected on the chart.

Remember, backtesting a strategy or EA is important before applying it to your live account. So, even if it does take a little more time than you had anticipated, it will be well worth the time investment.

Disclaimer

If you liked this educational article please consult our Risk Disclosure Notice before starting to trade. Trading leveraged products involves a high level of risk. You may lose more than your invested capital.