How Trading Strategies Are Backtested

17 July 2023

5m read

TL;DR
Do you believe you have innovative ideas for the market but are unsure of how to test them without putting your money at risk? A good systematic trader's bread and butter is their ability to backtest trade ideas.
Backtesting's fundamental tenet is that past successes might repeat themselves in the future. But how do you approach doing this on your own, and how do you assess the outcomes? Let's perform a quick backtesting procedure.

Introduction

One of the essential steps in creating your own charting and trading technique is backtesting. It requires using a system built on historical data to recreate trades that would have taken place in the past. You should be able to determine whether or not an investment plan is successful based on the backtesting results.

What Is Backtesting, Exactly?
First, read our post What Is Backtesting? if you want a deeper dig into the subject.
Backtesting's primary goal is to demonstrate the viability of your trading theories, to put it briefly. To begin, you use historical market data to see how a strategy would have fared. If the technique appears to have promise, it might also work well in a real-time trading environment.
What Should I Do Prior to Backtesting?
Your trading style must be established before you begin backtesting. Are you a systematic or a discretionary trader?
Discretionary trading relies on decisions; traders make their own timing decisions regarding when to enter and leave trades. It's an open-ended, loose strategy where the majority of choices are based on the trader's evaluation of the current situation. As a result, since the approach isn't clearly defined, backtesting is less important when it comes to discretionary trading.
It goes without saying that you should still backtest and paper trade if you're a discretionary trader. It simply indicates that the outcomes might not be as trustworthy as they are with systematic trading.
Backtesting is better appropriate for systematic trading. A trading system that specifies and instructs traders on when to enter and exit a trade is what systematic traders rely on. While systematic traders have complete control over the majority of the strategy's elements, it completely chooses their entry and exit signals. A straightforward technique could be thought of in the following two easy steps:
Enter a trade when A and B occur at the same moment.
Exit the trade after X has occurred.
This strategy is favored by some traders. It can make trading judgments free of emotion and offer a believable level of certainty that a trading strategy is successful. Naturally, there are still no assurances.
Because of this, it's crucial to ensure that your system contains very precise rules for when to enter or quit positions. A poorly defined plan will produce erratic outcomes. This trading approach is increasingly common in algorithmic trading, as one might anticipate.
If you wish to automate the procedure, you can purchase backtesting software; all you have to do is enter your own data, and the program will perform the backtesting on your behalf. But in this case, we'll use a manual backtesting approach. Although it takes a little more effort, it is totally free.

How Can a Trading Strategy Be Backtested?

This link will take you to a Google Sheets spreadsheet template. This is a basic template that you can use as a basis for making your own. It gives you a broad sense of the data that a backtesting sheet might include. There are no fixed guidelines; some traders choose to program it in Python or Excel. You are free to include as much data as you require as well as any additional information you may think is relevant.
Date
Market Side Entry
Avoid Loss
Consider 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 straightforward trading plan:

  • Following a golden cross, we purchase one Bitcoin at the first daily close. When the 50-day moving average crosses over the 200-day moving average, this is referred to as a "golden cross." At the first daily close following a death cross, we sell one Bitcoin. When the 200-day moving average dips below the 50-day moving average, this is referred to as a death cross.
    At the first daily close following a golden cross, we purchase one Bitcoin. When the 50-day moving average crosses over the 200-day moving average, this is referred to as a "golden cross."
    At the first daily close following a death cross, we sell one Bitcoin. When the 200-day moving average dips below the 50-day moving average, this is referred to as a death cross.
    As you can see, we've also specified how long the strategy will be effective. This implies we won't regard a golden cross on the four-hour chart as a trade tip.
    The example's time frame starts at the beginning of 2019. However, you could look much further back in the price action of Bitcoin's history if you wanted to get more precise and trustworthy results.
    Let's examine the trade signals that this system generates over the specified time period.
  • Purchase at $5,400 * Sale at $9,200 * Purchase at $9,600 * Sell at $6,700 and purchase at $9,000
    Buy @ ~$5,400
    Sell @ ~$9,200
    Buy @ ~$9,600
    Sell @ ~$6,700
    Buy @ ~$9,000
    The overlay of our signals on the chart looks like this:

Our first deal brought in roughly $3,800 in profit, whereas our second trade cost us about $2,900. Thus, our current realized PnL is $900.
Additionally, we're engaged in a transaction that had around $9,000 in unrealized profit as of December 2020. If we follow our original plan, we'll close this when the subsequent death cross occurs.

Analyzing the Results of Backtesting

What do these findings therefore indicate? Our plan would have produced a respectable return, but nothing particularly noteworthy has emerged thus far. The goal of backtesting would be defeated if we realized the open trade to significantly improve our realized PnL. The outcomes won't be reliable if we don't follow the plan.
Despite the fact that this is a methodical approach, the context should also be taken into account. The unsuccessful transaction from $9,600 to $6,700 took place at the time of the COVID-19 crash in March 2020. Any trading system may be significantly impacted by such a "black swan" event. This is yet another justification for more investigation to see whether this loss is typical or only a result of the method.
This is one illustration of a basic backtesting procedure. If we go back and evaluate this method with more data or add other technical indicators to maybe increase the signals it generates, it might have some promise.
But what more can you infer from backtesting outcomes?
Your maximum upside and drawdown are measured by volatility.

  • Exposure: The amount of capital from your whole portfolio that must be set aside to implement the plan.
    The strategy's percentage return over the course of a year is called its annualized return.
    Win-loss ratio: The proportion of trades in the system that are expected to end in a win as opposed to a loss. Average fill price: When implementing the approach, this is the average cost of your filled entries and exits.
    You can measure your greatest upside and drawdown with volatility.
    Exposure: The amount of capital from your entire portfolio that must be set aside to implement the plan.
    The strategy's percentage return over the course of a year is known as its annualized return.
    Win-loss ratio: The proportion of transactions in the system that are expected to end in wins against losses.
    Average fill price: When implementing the approach, this is the average cost of your filled entries and exits.
    Please keep in mind that the samples listed above are not all-inclusive. You have complete discretion over the metrics you choose to monitor. In any event, you'll have more chances to learn from the outcomes the more information you put in your trading log concerning pertinent set-ups. Some traders backtest very meticulously, which is likely to show in their outcomes.
    Optimization is a final point to take into account. You will understand the distinction between backtesting and forward-testing (also known as paper trading) after you have read our article on backtesting.

Concluding Remarks

The fundamental steps for doing a manual backtest of a trading system have been covered. But it's crucial to keep in mind that past success doesn't guarantee future success.
If you want to enhance your trading technique, you must adjust to changing market circumstances. Additionally, be careful not to put all your faith on the data. When it comes to assessing outcomes, common sense is a helpful — if frequently disregarded — instrument.

Additional Reading

Latest Releases