Archives

[Poll] What Is the Best Way to Backtest?

March 4, 2019 by Andriy Moraru

If you want to be sure that your strategy can yield better results than you would attain by simply buying and selling randomly, you need to test it. There are two ways of doing it: backtesting (when you use past data to see how the strategy works) and forward testing (when you use the strategy on demo or a small live account in real-time). Forward testing has one serious disadvantage — it will take you months or even years to test a strategy, whereas backtesting allows to do it in several minutes or hours.

Backtesting can be done either manually or in an automated way. Manually, you just scroll the chart from some point in the past into the future and look for how your strategy’s entry and exit signals would work out. When performing automated backtesting, you use special software, which runs your strategy against the chart data and produces a report with results for all executed trades. For this to work, your strategy has to be formalized in some way. Usually, it is done by coding an expert advisor (robot), which implements your strategy’s algorithm. However, some backtesting programs do not require coding and allow strategy input in a form of simple rules.

One of the biggest advantages of the automated testing software is that you can run your strategy multiple times on the same chart data but using a range of different input parameters to find the best combination of such parameters. This is called optimization, and although it is easy to over-optimize a strategy, it is a useful tool for strategy creation and analysis.

Now, I will briefly describe the most popular of the currently existing ways to backtest Forex strategies.

MetaTrader 4, being the most popular trading platform among retail FX traders, is also a tool of choice to backtest strategies. To use MT4 Strategy Tester, you first need to code an expert advisor based on your strategy. The Strategy Tester is quite powerful with visual mode, optimization, and several price data models (the most precise being Each tick). A very detailed report is available upon backtesting completion.

MetaTrader 5 is becoming more popular as a trading platform with each year, but is still not as popular as MT4. Despite that, its Strategy Tester is much better than that of its predecessor. In addition to all the features present in MT4, MT5 allows backtesting on real ticks data, custom trading symbols, using a part of a testing period for forward testing simulation, trading delay imitation, and cloud computing (more on this in the next paragraph).

MQL5 Cloud Network in MetaTrader 5 allows optimization and backtesting of calculation-heavy strategies using the computing resources deployed by other MT5 users around the world. This feature allows fast and cheap backtesting of huge numbers of strategies.

cTrader is less popular than MetaTrader when it comes to choosing a trading platform despite the fact that, in terms of backtesting, it offers the same features as MetaTrader 4 and also testing on real ticks data and timeframe optimization. It also requires coding your strategy into a program, which in cTrader is called bot.

NinjaTrader offers rather extensive toolset for backtesting strategies (which should be coded in C# in NinjaScript Editor). NinjaScript is less popular among Forex traders than MT4/MT5, however, its Strategy Analyzer offers more powerful features, except for lacking a cloud computing network. Unfortunately, using NinjaTrader is less straightforward than backtesting in MetaTrader and even cTrader.

Forex Tester, which currently is in its 3rd version, is a piece of software aimed at assisted manual backtesting but is capable of producing fully automated backtests on real ticks. Moreover, it can backtest multiple EAs on multiple currencies and multiple timeframes at the same time. It lacks optimization feature and is not as robust as MetaTrader/cTrader backetsting but, nevertheless, offers unique approach to the testing process. Forex Tester 3 works with its own sort of EA written using C++ and Borland Delphi API. Forex Tester 3 is a paid software. A free demo version is available but is quite limited in its backtesting capabilities.

TradingView offers traders a possibility to backtest strategies (coded in PineScript) via its platform’s web-based interface. The Strategy Tester is rather simple and lacks many features offered by the above-listed software. For example, optimization is not available and period selection is weird. However, it is a rather fast way to test some trading ideas using TradingView’s data and without need to install any software.

Excel is not a specialized Forex trading or backtesting software, but being a general-purpose spreadsheet application, it can be used for data analysis, and backtesting is exactly that. Setting up a backtesting spreadsheet in Excel is not easy — you need to have a good understanding of both the software and your strategies’ inner workings; you would also need to import all the data you might need into your workbook. Nevertheless, with no hard limits on what you can do with the data combined with the power of VBA, Excel is a viable backtesting tool used by many professionals.

My favorite backtesting platform is MetaTrader 5 due to the real ticks data and the power of MQL5 language for coding my strategies. When I need to optimize an expert advisor with more than 100,000 combinations of input parameters, I run it on MQL5 Cloud Network. Of course, I also use MetaTrader 4 because many expert advisors are coded for that platform and do not run on MT5. I used TradingView a couple of times to backtest some cryptocurrency trading strategies because PineScript is so easy-to-use when it comes to coding simple strategies and because the data is easily available on TradingView. My experience with testing in cTrader is rather limited (I would call it educational). And how about you?