Backtesting is one of the key components of developing your own charting and trading strategy. It’s done by reconstructing trades that would have happened in the past with a system based on historical data. The results of backtesting should give you a general idea of whETHer a trading strategy is effective or not.
And what we will be teaching today is backtesting trading strategies with an example so that you will be able to grasp the backtesting meaning easily. Let’s dive right into it!
Backtesting Meaning
Backtesting is a tool that you (as a trader or investor) can use when exploring new markets and strategies. The main purpose of backtesting is to inform you whETHer your trading ideas are valid.
You use past market data to see how a strategy would have performed. It can then provide some valuable feedback based on data and tell you whETHer your initial idea was valid. If the strategy looks like it has potential, it may also be effective in a live trading environment.
What to Do Before Backtesting
Before we start with the backtesting example, there is somETHing you should determine. You’ll need to establish what kind of trader you are. Are you a discretionary or a systematic trader?
Discretionary trading is decision-based whereby traders use their own judgment for when to enter and exit. It's a relatively loose and open-ended strategy, where most of the decisions are up to the trader's assessment of the conditions at hand. As such, backtesting is less relevant when it comes to discretionary trading since the strategy isn’t strictly defined. This doesn’t mean that you shouldn’t backtest or paper trade at all – it just means that the results may not be as reliable as in the other case.
Systematic trading is more applicable to backtesting. Systematic traders rely on a trading system that defines and tells them exactly when to enter and exit. While they have complete control over what the strategy is, the entry and exit signals are determined by the strategy. Some traders prefer this approach as it can eliminate emotional decisions from trading and provide a reasonable degree of assurance that a trading system is profitable. You could think of a simple systematic strategy as:
- When A and B happen at the same time, enter a trade.
- When X happens after, exit the trade.
Though, it is important to make sure that you have very specific rules in your system for when to enter or exit positions. If the strategy isn’t well-defined, the results will be inconsistent as well. As you might expect, this kind of trading style is more popular with algorithmic trading.
There is backtesting software out in the market that you can buy if you want to do automatic backtesting. You can input your own data, and the software will do the backtesting for you. However, in this example, we’ll go for a manual backtesting strategy. It’ll take a little bit more work, but it’s completely free.
Backtesting Trading Strategies
You can look up Google and find a spreadsheet that gives you a general idea of what information a backtesting sheet may contain. Some traders will prefer to use Excel or code it in Python – there aren’t strict rules here. You can add much more data and anything else you may deem useful to it.
Date | Market | Side | Entry | Stop Loss | Take Profit | Risk | Reward | PnL |
12/08 | BTCUSD | 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 backtest a simple trading strategy on this idea:
- We buy one Bitcoin at the first daily close after a golden cross. We consider a golden cross when the 50-day moving average crosses above the 200-day moving average.
- We sell one Bitcoin at the first daily close after a death cross. We consider a death cross when the 200-day moving average crosses below the 50-day moving average.
As you can see, we also defined the time frame where the strategy is valid. This means we won’t consider it a trading signal if a golden cross happens on the 4-hour chart.
For the sake of this example, we’ll only look at the time period going back until the start of 2019. However, if you’d like to get more accurate and reliable results, you could go back much further in Bitcoin’s price action.
Now, let’s see what trading signals this system produced for the period:
- Buy @ ~$5,400
- Sell @ ~$9,200
- Buy @ ~$9,600
- Sell @ ~$6,700
- Buy @ ~$9,000
Our first trade would have turned a profit of about $3800, while our second trade resulted in a loss of about $2900. This means our realized PnL is currently $900.
We’re also in an active trade, which, as of December 2020, has about $9000 unrealized profit. If we stick to our initially defined strategy, we’ll close this when the next death cross happens.
Evaluating Backtesting Results
So, what do these results show? Our strategy would have turned over a reasonable return, but it doesn’t show anything that outstanding so far. We could realize the currently open trade to drastically increase our realized PnL, but that would defeat the purpose of backtesting. If we don’t stick to the plan, the results won’t be reliable either.
Even though this is a systematic strategy, it’s also worth considering the context. The unprofitable trade from $9600 to $6700 was at the time of the March 2020 COVID-19 crash. Such a black swan event can have an outsized influence on any trading system. This is another reason why it’s worth going back further to see if this loss is an outlier or just a byproduct of the strategy.
In any case, this is how a simple backtesting process may look like. This strategy might have promise if we go back and test it with more data or include other technical indicators to potentially make the signals it produces stronger.
But what else can backtesting results show you?
- Volatility measures: your maximum upside and drawdown.
- Exposure: the amount of capital you need to allocate for the strategy from your entire portfolio.
- Annualized return: the strategy’s percentage return over a year.
- Win-loss ratio: how much of the trades in the system result in a win and how much in a loss.
- Average fill price: the average price of your filled entries and exits in the strategy.
These are just a few examples and not an exhaustive list by any means. What metrics you’d like to track is completely up to you. In any case, the more details you journal about the setups, the more opportunities you’ll have to learn from the results. Some traders are very rigorous in their backtesting, and it may also reflect in their results.
Closing Thoughts
And that is it on backtesting trading strategies with an example included, where we went through the basic process of how to do a manual backtest of a trading strategy. Remember, past performance isn’t a guarantee for future performance.
Market environments change, and you’ll need to adapt to those changes if you’d like to improve your trading. Generally, it’s also useful not to blindly trust the data. Common sense can be a surprisingly useful tool when it comes to evaluating results.





















