Summary
Do you think you have great ideas about the market but don't know how to test them without risking your money? Learning how to backtest trading ideas is one of the cornerstones of a successful systematic trader.
The basic premise of backtesting is that what worked in the past may work in the future. But how do you do it yourself? How can you evaluate the results? Let's go through the process of performing a simple backtest below.
the introduction
Backtesting is a key component of developing your own charting and trading strategy. This process entails reconstructing trades that would have occurred in the past through a system based on old data. The results of the backtest should give you a general idea of whether the investment strategy is effective or not.
What is backtesting?
If you first want to understand backtesting more deeply, you can check out the article titled What is Backtesting?.
In short, the whole point of backtesting is to determine the validity of your trading ideas, where you use market data from previous periods to see how the strategy would have performed. If the strategy proves to have good potential, it may also be effective in an existing trading environment.
What to do before backtesting?
Before starting backtesting, you should decide your trading approach, are you a systematic or discretionary trader?
Discretionary trading is decision-based — i.e. traders rely on their own judgment when it comes to entering and exiting trades. It is a flexible and unlimited strategy, with most decisions coming down to the trader's assessment of current conditions. As expected, backtesting will not be of much significance when it comes to discretionary trading since the strategy is not clearly defined.
This of course does not mean that if you rely on discretionary trading, you should not backtest or use paper trading at all, but it just means that the results may not be as reliable as they normally are with systematic trading.
Systematic trading is more suited to backtesting, as systematic traders rely on a trading system that determines when to enter and exit trades. While systematic traders control most aspects of the strategy, it is the strategy that determines the entry and exit signals for them. You can think of the simple systematic strategy in two simple steps:
When event (A) and (B) occur simultaneously, enter the trade.
When (c) occurs next, exit the trade.
Some traders prefer this approach, as it helps limit emotional decisions during the trading process, as well as providing a reasonable degree of assurance that the trading system is profitable, but of course, there are no guarantees.
This is why it is necessary to ensure that there are specific rules in your trading system regarding when to enter or exit trades. A strategy that is not clearly defined will lead to conflicting results. As you might expect, this type of trading method is more common in algorithmic trading.
There is backtesting software you can purchase if you want to automate the process — you simply enter your data and the software does the backtesting for you. But in this example we will look at a manual backtesting strategy. It takes a little more work, but it's completely free.
How to backtest a trading strategy
At this link you'll find a Google Sheets spreadsheet template, which is a prototype that you can use as a starting point for creating your own, and gives you a general idea of what information a backtest log might include. Some traders prefer to use Excel or write some code in the Python programming language, as there are no strict rules, and you can add any amount of data as you wish, as well as any other information that you may find useful.
Well, let's start by backtesting a simple trading strategy:
We will buy 1 Bitcoin on the first daily close after a golden cross occurs. A golden crossover occurs when the 50-day moving average crosses above the 200-day moving average.
We will sell 1 Bitcoin at the first daily close after the death cross occurs. A death cross occurs when the 200-day moving average crosses below the 50-day moving average.
As you can see, we have also identified the time frame in which the strategy is applicable. This means that if a golden cross occurs on a 4-hour chart, we will not consider it a trading signal.
The time period in this example starts at the beginning of 2019. But if you want to get more accurate and reliable results, you can go back to a larger period of time in the history of Bitcoin price movements.
We will now see what trading signals this system produced during the specified time period:
Buy at $5,400
Selling for $9,200
Buy at $9,600
Selling at $6,700
Buy at $9,000
Below we explain what the signals look like when they are overlaid on the chart:
The first trade generated profits of approximately $3,800, while the second trade resulted in losses of approximately $2,900. This means that the realized profit and loss is currently $900.
We also have an active trade that, as of December 2020, recorded an unrealized gain of approximately $9,000. If we stick to the strategy specified at the beginning, we will close the trade when the next death cross occurs.
Evaluate backtest results
So what do these results show? The strategy we applied was supposed to provide good returns, but it has not shown any outstanding results so far. We can recognize that a currently open trade may significantly increase the realized profit and loss, but this defeats the purpose of backtesting. If we do not stick to the plan, we will not get reliable results.
Although this strategy is methodological, it is also necessary to study the context. The unprofitable trade was $9,600 to $6,700 at the time of the market crash as a result of the coronavirus pandemic in March 2020. This unexpected event can have a massive impact on any trading system. This is another reason why it is important to look back over a larger period of time to see if these losses are out of the ordinary or a byproduct of the strategy.
This is an example of a simple backtesting process. This strategy could be promising if we test it with more data or by including other technical indicators to strengthen the signals it produces.
But what else can the backtest results show?
Volatility measures: maximum ups and downs.
Exposure: The amount of capital you need to allocate from your entire investment portfolio to implement the strategy.
Annual Returns: The percentage of the strategy's returns over the course of a year.
Profit to Loss Ratio: The number of trades in the system that are likely to generate profits as well as the number of trades that are likely to generate losses.
Average execution price: The average execution price of entry and exit operations when using the strategy.
You should keep in mind that these previous examples do not represent an exhaustive list. It's up to you to choose which metrics you want to track. In any case, the more details you record in your trading journal about the relevant settings, the greater your chances of learning from the results you obtain. Some traders take a very strict approach when backtesting, which is likely reflected in the results they get.
Another thing to consider is optimization. If you have read the article about backtesting, you will understand the difference between backtesting and forward testing (or paper trading).
Concluding thoughts
We've gone over the basic steps of how to manually backtest the trading strategy we use. But it is important to remember that past performance does not guarantee future performance at all.
Markets change, and you must adapt to these changes if you want to improve your trading strategy. You should also be careful not to trust the data blindly. Common sense and intuition are very useful—but often overlooked—tools when it comes to evaluating results.
Related articles
A beginner's guide to learning crypto swing trading
What is meant by budget trading?
What is a trading journal and how to use it
What is scalping trading in digital currencies?
What are behavioral biases? How can we avoid it?
