What is a Backtesting in Trading?

We all have already seen amazing backtesting in trading: 99% are false! This is the first article of a series that will explain to you, what is a backtesting in trading? Why is it so important (especially in algorithmic trading)? And how should you do a backtesting in trading? Spoiler alert: not in the way you are thinking…

1. BACKTESTING IN TRADING: DEFINITION AND GOALS

Basically, a backtesting in trading is here to understand the behavior, the performance and the risk of a trading strategy. To do so, you will take a trading strategy and apply it to historical (or generated) data. Depending on your trading strategy, you will focus on many backtesting metrics, but the most used backtesting metrics are:

  • Return / year: you take the average return per year you are backtesting your trading strategy.
  • Drawdown: The drawdown will give you the worst diminution of your net value (if your highest capital was 15,000$ and now you are now at 10,000$, you have a drawdown about 1 – 10,000/15,000 = 33%. It is the most used metric to understand the risk.
  • Sharpe ratio: This metric, very well known in finance, will give you the additional return obtain by increasing your risk of 1% (if your Sharpe Ratio is about 2, it means that, when you are increasing your risk by 1%, you are increasing your return by 2%)

Figure: Example of an output from a backtesting in trading

2. THE ART OF BACKTESTING IN TRADING

You can take the same strategy on the same data and show me an amazing backtest which is exactly what people on copy trading or bot selling platforms do 99% of the cases.

I can take the same strategy on the same data and show you that this strategy is overfitted, not profitable and only good for the trash… But why? Backtesting in trading is a scientific process. Indeed, some people take 10 years to master this field totally, and I will explain to you all you need to know about it in this series of articles.

The most frequent reason why all your backtests are good is that you are using the backtest like a research tool. But, in reality, you should use it only once per strategy, at the very end. The goal is to say if yes or no we need to go deeper into the trading strategy building process. (I will give you the worst backtesting mistakes in the next article).

Exclusive offer. Do not miss it!

Obtain 1 week of content 100% Free !

  • The Basics of Quant Finance
  • The Biggest Backtesting errors
  • The Scientific Backtesting Guide
  • Prerequisites to break into quant finance
  • Technical indicators in python
  • Create your first Trading Strategy in Python
  • Full Details about my ML Reversal FX Strategy

3. STOCK PRICES ARE RANDOM, INTEGRATE IT IN YOUR TRADING BACKTESTING

What does it mean “Stock prices are random”? It means that the variation that a stock price will occur is totally random. It doesn’t mean that we can’t predict the distribution of this randomness… We will not go deeper into that in the backtesting section, but it is important to keep it in mind.

In other terms, the past could be different. If the COVID-19 has never been discovered and we all thought it was just like a simple cough, we would not suffer from this micro financial crisis. If the COVID-19 hadn’t stopped our economy, the countries would not have to borrow money, which didn’t make the inflation increase and so on…

Figure: Possible past values for the asset price

4. SIMPLE PATH BACKTESTING

The simple path backtesting method is easy to understand taking the historical data, apply your strategy on it and analyze the graphs and the metrics you are obtaining. Of course, the only precaution you need to take (like for the multiple paths method) is to never backtest your strategy on data you have already seen.

It means if you took the 2015-2020 to understand that the doji chart pattern works well when we are into a consolidation zone, you can’t backtest the strategy you have created on the 2015-2020 data, because obviously the performances will be amazing because you have used this dataset to do your research: Backtesting is not a research tool!

Backtesting in trading is here to validate (or invalidate 95% of the cases) a strategy. So, you need to use the remaining data to test your trading strategy: from 2020 to 2024.

The problem of that approach is that you will take the historical data path only, which is only one possible path that the past could be!

5. MULTIPLE PATHS BACKTESTING

On the other hand, the multiple paths backtesting can be done in several ways: taking the historical data in a different order creating several datasets like for the walk-forward optimization or for the robustness testing or you can generate new data like for the Monte-Carlo simulation method.

Personally, I combine all these methods and much more to create a score to my strategy: the more the score is close to 10, the more the strategy is amazing (robust and profitable).

Figure: Example of an output from a CPCV (robustness testing)

But, let me define quickly what I mean by robust. A robust trading strategy is a strategy that will not see its performance varies too much when we modify some parameters (like an elasticity in economy): let’s assume I’m using a 100-period SMA, and the performance is amazing. If I take a 99-period SMA without changing anything else and the performance becomes awful. It means that the strategy is not robust because a small change can ruin your strategy.

Indeed, if your strategy performance depends on a tiny modification like that and we know that the future as the past is random, how could we imagine that this strategy will be consistently profitable in the long run?

In basic word, the multiple paths method is like splitting our database in several datasets and we apply the single path method on it, then we aggregate the results to understand the standard deviation from them: the more they are different on different datasets, the worst it is.

Previous Article

The Scientific Backtesting Guide

Next Article

The 6 Biggest Portfolio Backtesting Mistakes

Write a Comment

Leave a Comment

Your email address will not be published. Required fields are marked *