top of page

How to Backtest a Trading Strategy

Are you concerned that you have great ideas about the market but cannot put them into practice without risking your money? A good systematic trader must learn how to backtest trade ideas.

Backtesting is based on the principle that what has worked in the past, may also work in the future. The question is: how to accomplish this on your own? As well as how should you evaluate what you get? Let's take a look at a simple example of backtesting.

Introduction

Backtesting is one of the most important steps involved in developing your own trading and charting strategy. A system based on historical data allows for the reconstruction of trades that would have taken place in the past. An investment strategy's results should give you an idea of whether it is effective or not based on the results of a backtest.

What is backtesting?

To begin with, if you'd like to take a deeper dive into the concept of backtesting, read our article What is Backtesting?.

Backtesting has a basic purpose, which is to permit you to know if your trading ideas are valid. Through the use of historical market data, you can examine how a trading strategy might have performed. If you feel a strategy has potential, you may also be able to use it in a live trading environment if it seems that it has the potential.

What to do before backtesting

There is something we need to determine before we begin to work on the backtesting example. The first thing you should establish is what kind of trader you are. Would you classify yourself as a discretionary or systematic trader?

Trades that are discretionary require traders to make their own judgments about when to enter and exit the market. As a general rule, it is a fairly loose and open-ended strategy, where the majority of the decisions are determined by the trader's assessment of the current market conditions. The backtesting of a discretionary trading strategy is less relevant when it comes to discretionary trading since the strategy is not strictly defined.

Obviously, this does not imply that if you're a discretionary trader, you shouldn't be backtesting or paper trading at all. It simply means that the results may be less reliable in this case as opposed to the other case.

Trading based on systems is more applicable to our topic. The systematic trader relies on a trading system that tells him or her precisely when to enter a trade and when to exit a trade. Despite the fact that they have full control over the strategy they are employing, the entry and exit signals are dependent on the strategy. For example, you could think of a simple systematic strategy as follows:

  • The time when A and B occur simultaneously is a good time to enter a trade.

  • Then, exit the trade when X occurs after.

 

Many traders prefer to use this approach. Using a trading system that is mathematically sound can eliminate the need for emotional decisions and can provide a reasonable degree of assurance that the system is profitable. However, there is still no guarantee that the system will work.

That is why it is so crucial for you to have very specific rules defining when you want to enter or exit positions in your system. It is also important to note that when the strategy isn't well-defined, the results will be inconsistent. There is no doubt that this kind of trading style tends to be more popular with algorithmic trading than with manual trading.

There are a number of backtesting software programs that you can purchase if you want to continue automating your backtesting process. With the software, you will be able to input your own data and the software will do the back-testing for you. However, in this particular example, let us opt for a manual backtesting strategy. It's going to take a while, but it's completely free and easy to do.

How to backtest a trading strategy

Let's now take a look at a simple trading strategy that can be backtested.

  • A purchase of one Bitcoin is made at the first daily close after a golden cross. A golden cross is considered to occur when the 50-day moving average crosses above the 200-day moving average.

  • We have sold one Bitcoin at first close after a death cross has occurred. We consider the crossing of the 200-day moving average below the 50-day moving average as a death cross.

 

The strategy is also valid for the given period of time. We will not consider a golden cross on the 4-hour chart to be a trading signal, so in this case we will not view it as a signal.

For the purposes of this example, we will only be looking at the period that goes back to the beginning of 2019. For more accurate and reliable results, you can also go back much further in the price history of Bitcoin in order to get a more detailed analysis.

bottom of page