Backtesting a trading strategy

There are countless ways of making money in forex. But how can we ensure that our strategy will work in the long run? The truth is that we can never know 100% as markets are ever-changing organisms. The good news is that we can get very close to profitability thanks to backtesting. In this lesson, we will take a look at backtesting basics and show you how you can make the most of it to gain confidence in trading.

Guide to forex backtesting – gain confidence in trading strategy

One thing connects all professional traders – they have 100% trust in their trading strategy. If we want to join this elite club of traders, we must know what to expect from our trading strategy. This is quite a complicated task since none of us can see the future, but thanks to the historical data, we can easily see how we would have performed in the past. If we can find out that our trading strategy performed well in the last couple of years, there is a very small chance it won’t work in the future.

So what is backtesting?

While we backtest, we put our strategy to the test on historical data. This can be done over the last few months, but we can also go 10 or 20 years back. It all depends on our appetite and how robust we want our backtest to be. Although backtesting can be very time-consuming, it is relatively easy. All we need is a trading platform with enough historical data and a simple Excel sheet where we will document all trades.

Types of backtesting

There are two types of backtesting, manual and automated.

Manual backtesting is as straight as it gets. We need to open the platform and look daily for valid trading setups we would trade in real-time. After every trade, we log it into our spreadsheet and carry it on. This can be quite a long process; most importantly, we must be 100% true to ourselves. One of the mistakes traders make with backtesting is they try to “curve-fit” strategy so it would bring a positive expectancy. An example of this can be when the trading setup would present itself in the middle of the night where we won’t be able to execute it, or our Stop Loss would get hit by spread and we completely ignore this fact and register the trade as profitable anyway. We must realize that we are only hurting ourselves by doing this as we will lose money in the live market conditions.

The second type of backtesting is fully automated. We often need knowledge of some programming language for this type of backtesting. It is mostly Python, MQL or C++. You can also use some third-party online software. A huge advantage of automated backtesting is that it completely removes all the daily emotions and time we need to spend on historical data. The downside of it is that we need to invest quite some time in learning the programming language or understanding third-party online software.

Don’t forget about forward testing

Another type of testing that is just as important as backtesting, is forward testing, also called walk forward testing or paper trading. Compared to backtesting, where we look at historical data, in forward testing we use real time market data to test our strategies.

This type of testing is very important, because it allows us to see trading examples as they happen in real time. By doing so, we can eliminate some of the shortcomings that result from backtesting, such as historical bias or curve-fitting, while also being able to observe how our strategy reacts to news and macro data releases.

Important backtesting statistics

When we are running a backtest, these are the most important statistics we should keep track of.

  • Time and date of entry
  • Entry and exit price
  • Position size and % risk on our trading account
  • MAE – maximal adverse excursion
  • MFE – maximal favourable excursion
  • Average RRR ratio
  • Strike rate
  • Maximum drawdown
  • Long/short ratio
  • The success rate on different instruments

If possible, adding the screenshot to all the trades in our backtest is also good. This way, we can easily come back to it later.

How many trades should be backtested?

Some traders might test the first ten trades, and if they see their strategy works, they decide it is just enough and give up on further backtesting. This is definitely not a good approach as we don’t have a robust data sample. To be really sure our trading system is stable and robust, we need a sample size of at least 100-200 trades. This way, we will gain much more confidence in our trading. Although trading in the real market is always different from testing the strategy on the demo, we will gain much more confidence knowing that our strategy has a positive expectancy over the long run.