Backtesting can be an important step in optimizing how you engage with financial markets. It helps you learn whether your trading ideas and strategies make sense and if they could potentially turn a profit.
Backtesting is a tool that you (as a trader or investor) can use when exploring new markets and strategies. It can provide some valuable feedback based on data and tell you whether your initial idea was valid.
Regardless of the asset classes you trade, backtesting doesn't require you risking any of your hard-earned funds either. Using backtesting software in a simulated environment, you can build and optimize a particular approach to a market. Let's dive in.
What is backtesting?
In finance, backtesting looks at the viability of a trading strategy by testing how it would have done based on historical data. In other words, it uses past data to see how a strategy would have performed. If backtesting shows good results, traders or investors may go ahead and apply the strategy to a live environment.
But what do good results mean in this case? Well, the purpose of a backtesting tool is to analyze the risks and potential profitability of a particular strategy. The investment strategy can be optimized and enhanced based on statistical feedback to maximize the potential results. A well-conducted backtest can also provide assurance that the strategy is at least viable when implemented in a real trading environment.
On a more professional level, backtesting trading strategies is absolutely essential, especially when it comes to algorithmic trading strategies (i.e., automated trading).
How does backtesting work?
Backtesting with a misleading data set can lead to less than ideal results. This is why it's crucial to find a good sample for the backtesting period that reflects the current market environment. This can be especially difficult, as the market is in a constant state of change.
Before you decide to backtest a strategy, it can be helpful to determine what exactly you would like to find out. What would make the strategy viable? Conversely, what would falsify your assumptions? If you know these beforehand, it will be more difficult for the results to affect your biases.
Backtesting should also include trading and withdrawal fees, and any other cost that the strategy may incur. It's also worth noting that backtesting software can also be quite expensive, just as access to high-quality market data is.
Here’s our trading system:
- We buy Bitcoin at the first weekly close above the 20-week moving average.
- We sell Bitcoin at the first weekly close below the 20-week moving average.
This strategy produces only a few signals per year. Let’s look at the time period starting from 2019.
Bitcoin weekly chart since 2019.
The strategy produced five signals in the measured timeframe:
- Buy @ ~$4,000
- Sell @ ~$8,000
- Buy @ ~$8,500
- Sell @ ~$8,000
- Buy @ ~$9,000
So, our backtesting results show that this strategy would have been profitable. Does this mean it’s a guarantee it will continue to work? No. It just means that looking at this specific data set, the strategy would have turned a profit. You could think of this result as a rough benchmark.
Bear in mind; we only looked at less than two years of data. If we’d like to turn this into an actionable strategy, it may be worth going back further in time and test it with more price action.
Backtesting vs. paper trading
So, now we have a rough idea of what backtesting may look like and had a look at a very simple investment strategy. We also know that past performance is not indicative of future results.
Paper trading is the simulation of a strategy in a live trading environment. It's called paper trading because while the trades are documented and logged, no real funds are used. This provides you with an additional step where you can improve the strategy and get an idea of its performance.
Something to be wary of here is "cherry-picking." This refers to selecting only a subset of data to confirm a biased viewpoint. The point of forward testing is to test out the strategy as if it would happen in real-time. If the system tells you to do something, do it. If you only pick trades that "look good" based on your personal bias, then the test for the systematic strategy won't be valid.
Manual vs. automated backtesting
Manual backtesting involves analyzing charts and historical data and manually placing the trades according to the strategy. Automated backtesting does essentially the same, but the process is automated by computer code (using programming languages like Python or specialized backtesting software).
The maximum drawdown represents the moment at which your trading strategy had the worst performance relative to the last peak (i.e., the biggest percentage drop your portfolio had during the analyzed period).
Many systematic traders and investors heavily rely on backtesting for their strategies. It's one of the essential instruments in the toolkit of any algo trader.
At the same time, interpreting backtesting results can be tricky. It's easy to imprint your own biases into the backtesting method. Backtesting alone likely won't create viable trading strategies, but it'll help you test some ideas out and keep your finger on the pulse of the market.