Summary
Do you think you have a great idea about the market, but don't know how to put it into practice without losing real money? Knowing how to backtest trading strategies is an essential ability of a good systematic trader.
The premise behind backtesting is that what worked in the past may work in the future. But how do you perform backtesting, and how do you evaluate the results? Let’s walk through a simple backtesting process.
Backtesting is the key to developing your own charting and trading strategies One of the elements. It uses a system based on historical data to reconstruct transactions that may have occurred in the past. The results of a backtest will give you a rough idea of whether an investment strategy is working.
First of all, if you want to know more about what backtesting is, you can read our article "What is backtesting?" 》
In short, the main purpose of backtesting is to show you whether your trading idea works. You can start by using past market data to see how your strategy is performing. If this strategy looks like it has potential, it's likely to work in a real trading environment as well.
Before you start backtesting, you need to determine what type of trader you are. Are you a autonomous decision-making trader or a systematic trader?
Discretionary trading is decision-based — traders use their own judgment to decide when to open and close positions. This is a relatively loose and open-ended strategy, and most decisions depend on the trader's assessment of the situation at hand. Therefore, backtesting is less important in discretionary trading, as this strategy is not strictly defined.
Of course, this does not mean that if you are a discretionary trader, you should not use backtesting or simulated trading at all. This simply means that the test results are less reliable than those obtained by systematic traders.
Systematic transactions are more suitable for backtesting. Systematic traders rely on a trading system that defines and informs when to open or close a position. Systematic traders control most aspects of the strategy, but the timing of opening and closing positions is entirely determined by the strategy. You can think of a simple systemic strategy as a two-step process:
When A and B happen simultaneously , enter the transaction.
When X occurs, exit the transaction.
Some traders prefer this method. It can eliminate emotional decision-making in trading and provide reasonable guarantee for the profitability of the trading system. Of course, no guarantees are absolute.
That's why it's important to make sure you have specific rules in place in your system about when to open or close a position . If the strategy is not clearly defined, the results will be inconsistent. As you might expect, this trading style is more popular among algorithmic trading.
If you want to automate the process, you can purchase backtesting software — you just enter your data and the system does it for you Perform backtesting. But in this example, we’ll introduce you to a manual backtesting strategy. It takes a little more work, but it's completely free.
You can find the Google spreadsheet template through this link. You can create your own template based on this basic template. It can give you an idea of what information a backtest spreadsheet might contain. Some traders prefer to use code in Excel or Python, there are no strict rules in this regard. You can add the data you need, as well as any other information you find useful.
Date | Market | Direction td> | Open a position | Stop loss | Take profit | Risk | Rewards | Profit and loss |
12/08 | BTCUSD | Go long | $18,000 | $16,200 | $21,600 | 10% | 20% | 3600 |
12/09 | BTCUSD | Short | $19,000 | $20,900 | $13,300 | 10% | 30% | - 1900 |
Let’s deal with some simple Trading strategy for backtesting:
We bought at the first daily close after the golden cross Deposit one Bitcoin. We believe that when the 50-day moving average is above the 200-day moving average, it is a golden cross.
We sell one Bitcoin at the first daily close after the death cross. We believe that when the 200-day moving average is below the 50-day moving average, it is a death cross.
As you can see, we also define the time frame during which the policy is valid. That is, if a golden cross appears on a 4-hour chart, it will not be considered a trading signal by us.
The time period in this example begins in early 2019. However, if you want to get more accurate and reliable results, you can go further back into Bitcoin’s historical price action.
Now, let’s take a look at what trading signals the system generated during this period:
Buy @ ~$5,400
Sell @ ~$9,200
Buy @ ~$9,600
Sell @ ~$6,700
Buy @ ~ $9,000
Here is what our signal looks like when overlaid on the chart:
Our first transaction The profit on the trade was approximately $3800, while the second trade would result in a loss of $2900. This means our realized P&L is $900.
We are also actively trading, with unrealized profits of approximately $9,000 as of December 2020. If we had stuck to our original strategy, we would have closed our position at the next death cross.
So, what do these results say? Our strategy is supposed to deliver reasonable returns, but so far there hasn't been any stellar performance. We could significantly increase our realized P&L by executing current open trades, but this defeats the purpose of backtesting. If we don’t stick to the plan, the results won’t be reliable.
Even if this is just a system strategy, it should still be considered in the specific context of the time. The unprofitable trades from $9600 to $6700 occurred during the March 2020 crash caused by the coronavirus pandemic. Such black swan events can have a huge impact on any trading system. Because of this, we need to look further back to understand whether this loss is an anomaly or just a side effect of the strategy.
This is an example of a simple backtesting process. If we go back and test it with more data, or incorporate other technical indicators it might give it a stronger signal, making the strategy more promising.
But what else can the backtest results tell you?
Volatility Measurement: Your maximum upswings and drawdowns.
Risk Exposure: The amount of money you need to allocate from your entire portfolio to execute this strategy.
Annualized Return: The percentage return of this strategy over one year.
Profit and Loss: How many transactions in the system are likely to be profitable and how many transactions are likely to be losses.
Average transaction price: The average price of the opening and closing positions you executed in the strategy.
Please know: the above example is not sufficient to fully illustrate the role of backtesting. It’s entirely up to you which metrics you want to track. Regardless, the more details you record in your trading journal about your setup, the more opportunities you have to learn from the results you get. Some traders are very strict with their backtesting, and this may be reflected in their results.
The final factor to consider is optimization. If you have read our backtesting article, you will know the difference between backtesting and forward testing (paper trading).
We have seen the basic process of manual backtesting of trading strategies. But it's important to remember that past performance is no indication of future performance.
The market environment is changing rapidly, and you must adapt to these changes if you want to improve your trading strategy. You also need to remember that you cannot blindly trust data. Common sense, although often overlooked, is also a very useful tool when evaluating results.
Swing Trading Cryptocurrencies Beginner's Guide
What is arbitrage trading?
What is a trading journal and how to use it
What is cryptocurrency short-term trading?
What is behavioral bias? How to avoid behavioral biases?