Backtesting a strategy can be labor-intensive, and the testing process can be complicated. But, backtesting is ultimately a key component of developing an effective trading system. It involves the process of running a specific strategy through historical data or past market data to see how it would have performed. This gives a clear overview of non-qualified strategies before committing real capital to real-world markets.
However, if backtesting is not performed correctly, the results will be erroneous, causing preventable losses. Backtesting trading strategies usually apply to the Forex and stock market, but it works perfectly for the cryptocurrency market too. In any trading environment, greater amounts of data tend to lead to better quality backtests.
This guide will cover what crypto backtesting is, why it matters, and the differences between manual backtesting and systems backtesting. We’ll also cover the types of data best suited for backtesting a crypto strategy and what performance metrics to consider when analyzing the strategy’s performance.
What Is Backtesting?
Backtesting means applying a trading strategy or analytical method to historical trading data to see how the strategy or method has performed. If the crypto strategy shows promise and performs well, the trader may apply the strategy to a live environment.
Backtesting historical performance does not guarantee future results, but backtesting can be a reliable method to filter the effective strategies from the ineffective ones if conducted properly. Still, unreliable data can affect the backtesting process.
Why Does Backtesting Matter?
Backtesting offers traders and investors a way to evaluate and optimize their analytical models and trading strategies before implementing them. If the strategy you’ve created performed poorly in the past, it may perform poorly in the future. The opposite is true if the strategy has performed well in the past.
In that case, it’s assumed the strategy will continue to perform well into the future, given similar conditions. For example, a systematic trader tends to look at the macroeconomic and predicts the market trends using technical signals can rely on backtesting to detect the recurring patterns and exploit them for profits.
Discretionary vs. Systems Backtesting
There are generally two different ways to backtest trading strategies. A discretionary strategy or discretionary investment strategy is when the trader manually places buy and sell trades. One way they might test their strategy is by manually backtesting.
Systematic traders strategically use algorithms to decide buy and sell signals. Then, a computer system places those buy and sell orders in the market. A systematic trader has their strategy coded and runs tests against historical data.
Each strategy has its pros and cons, so let’s review them.
Manual Backtesting: Is It Right for You?
A discretionary trader makes a conscious decision with each signal they receive whether to place that buy or sell signal in the market. Before applying their strategy to the live environment, the discretionary trader will want to test their strategy out on historical data.
The discretionary trader may decide to conduct a manual backtest using software such as TradingView.
For example, a trader using a simple moving average crossover strategy will place the moving averages on their price chart to simulate their strategy. Next, the trader will press the replay button and select a period in history to start the test.
Then, as they activate the replay, the market’s candles will appear on the screen, and the trader will make the discretionary decision to buy or sell, based on the signals documenting those trades on an Excel spreadsheet.
Manual backtesting is a great way to train yourself to control your emotions. You may feel some of the same emotions during the manual backtest as you would in a live environment. In addition, the manual backtest will give you a sense of how the strategy works and if the rules of the strategy are clear.
However, there are several cons to manual testing. The most obvious obstacle is that manual backtesting is quite time-consuming. You could spend hours running a test, only to find out that it wasn’t a great strategy. (However, that information too can be valuable.)
Secondly, the manual test is not robust, as the amount of data you would test the strategy on is limited. Lastly, trading costs are not simulated, and the trader will need to provide estimates in their spreadsheet log.
Systematically Backtesting a Strategy
A systematic or program trader has the benefit of technology on their side. Systems traders will have a strategy coded and then tested against historical market data.
Due to the processing power of computers and the convenience of certain software, systems traders can test their strategies over long time horizons while also optimizing certain inputs to the strategy. Systems traders use the backtest to generate statistics about their strategy to help identify robust or poorly developed schemes.
The challenge for systems traders is having the know-how to create an algorithmic strategy, coupled with the knowledge to analyze whether or not the strategy is robust.
In the end, accessing high-quality data will be as important as any other tool in the systems trader’s toolbox.
Historical Data Requirements
Systems traders will want to simulate the real-world market as closely as possible. For example, trading costs such as commissions, exchange spreads, and slippage can chew away at returns. Though the effect on an individual trade may be small, these small pieces of data can throw off the backtest results if they are ignored.
A couple of different types of market data are used in systems backtesting that you need to be aware of. Candlestick and order book data are both used in backtests, but order book data is usually more reliable.
OHLCV Candlestick Data
The OHLCV (Open-High-Low-Close-Volume) candlestick data is essentially a spreadsheet of OHLC price data for each interval of the chart time frame. For example, if you pull the candlestick data for the daily chart on Bitcoin, you’ll receive a spreadsheet of each day’s open, high, low, and close price data. For 1-minute data, the spreadsheet will include each minute’s open, high, low, and close price for Bitcoin.
There are several imperfections to this OHLCV candlestick data. First, you have no idea which prices have been traded for which volume. Additionally, if you’re trading the strategy in a large account, there’s no guarantee there will be enough liquidity to support your trading activity without moving the market. To put it another way, if you’re making large trades because you have a larger account, there might not be enough crypto available to trade, which could negatively impact your backtest results.
Traders typically call on candlestick data because it is the easiest to acquire. However, the results you receive from a candlestick backtest are unreliable and may not offer the benefits you’re looking for.
Order Book Data
An order book is one of the best data sources that resolve many of the challenges of candlestick data. Order book data includes snapshots of the market, including the market’s price, volume, and depth. With order book data, you’ll have a better representation of what orders are available at any given time.
Order book snapshots allow developers to simulate bid-ask spread, slippage, and liquidity when testing a strategy.
The challenge with order book snapshots is that the data may be difficult to come by. There is a tremendous amount of data within order book snapshots, and exchanges choose not to hold the data, as it would be expensive to store. Therefore, a developer needs to collect and store data from the exchange itself or access the order book snapshots through a third-party service.
Algorithmic trading (aka automated trading or black-box trading) refers to traders who use a computer program to define a set of instructions to execute a trade. Thus, the backtesting of strategies can also be automated. By implementing automation, we can also automate the results to arrive at helpful statistics, helping us determine if the strategy will be effective.
Performance from the trading system is commonly gauged against parameters such as profit and loss (P&L), success (win) ratio, and Sharpe ratio.
Deciding on a Programming Language
Before choosing a platform to backtest a strategy, make sure your preferred markets are supported. Also, choose which programming language you would like to use. Common programming languages include C++, R, MATLAB, and Python backtesting.
Some third-party services and API extensions you can subscribe to provide the back-end data and a front-end platform that is a little easier to backtest. Altrady, Holderlab, and Shrimpy are a few examples.
Once you’ve created your strategy and pushed the backtest button, the big number you’ll be interested in is the profit number. The backtest needs to spit out a profit and loss analysis by trade and day. That way, you can create an equity curve that shows what the account balance would have been if it were traded live.
The equity curve is simply a time series chart showing the value of the account balance each day or after each trade.
Also generated from the P&L analysis is the size of the average winner versus the size of the average losing trade. When you take the ratio of those two averages, you’ll end up with an average risk-to-reward ratio.
For example, if the average winning trade is $100 and the average losing trade is $50, this generates an average 1:2 risk-to-reward ratio ($50:$100).
Success Ratio and Sharpe Ratio
The success ratio is the win ratio of the strategy. If a strategy makes 100 trades, and 58 of the trades are profitable, it has a 58% success (or win) ratio.
By itself, however, the win ratio means nothing and is misleading. It’s best to couple the success ratio with the average winner and the average losing trade mentioned above.
For example, if the strategy has a success ratio of 58% and a 1:2 risk-to-reward ratio, this indicates a very profitable strategy.
Another metric used to determine how robust a strategy maybe is the Sharpe ratio, which illustrates what the returns are like on a risk-adjusted basis. This allows the trader to compare two completely different strategies based on the risk taken to yield those returns.
Simulated backtesting simply means running a test over historical data that simulates the market environment. An automated backtest is conducted using programming and code to speed through the process. Testing several months of data takes just a few minutes, depending on the speed of the computer.
By contrast, a manual backtest simulates the historical market as a trader selects a predetermined point in time, then walks forward the market to determine if a buy or sell signal is generated. The time involved in a manual simulation is much longer, which is prone to several possible errors.
How to Backtest Bitcoin Trading Strategies
There are a few different ways to backtest a Bitcoin trading strategy. To determine which is best for you, consider the following questions:
- Do you know how to program and code?
- Are you willing to pay for a third-party service to backtest?
If you’re a coder and developer, then you’ll have more options available to you. It will likely be best for you to generate your own backtest in the programming language you’re most comfortable with. This provides you with more flexibility and control over what you can do and any tweaks needed to improve your strategy. C++, R, MATLAB, and Python are common languages traders use to code, but obtaining high-quality data can still be challenging.
If you don’t want to code your own backtest, you can subscribe to third-party software as a service or use automated backtesting software. Generally, these services allow you to create your strategy on their platform and then run the strategy against the historical data. There is some convenience they provide to you, but you lose control over the reliability and quality of the data. Of course, these services will come with a cost as well.
If you’re looking for the least expensive method to backtest a Bitcoin trading strategy, then consider developing the strategy yourself and manually backtesting it. This will be the most time-consuming method, but it does allow you to see how the strategy performs and reconstructing trades based on your likings. Trading costs such as spread and slippage tend to be overlooked with this method, so make sure you include an estimate for them.
Evaluating the Backtesting Results
Though inexperienced traders will simply focus on the net P&L, it’s important to consider the bigger picture of the strategy. The success ratio, average winning trade, average losing trade, and Sharpe ratio are important to understanding the backtest and must be considered.
In addition, consider how long of a backtest period was chosen. The longer the backtest period, the more likely the results will include multiple market conditions. Shorter backtest periods will less likely be a good reflection of robust strategies.
Finally, what was the maximum drawdown?
The maximum drawdown is the amount of the account lost during an aggressive losing streak. Drawdowns will always occur, and if the drawdown is too large, you may not have enough capital to support the strategy. This becomes compounded when you’re trading leveraged products. Many systematic traders will advise you to expect a drawdown at least 50% greater than that realized on a backtest. This is because future drawdowns in a real environment tend to be bigger than those simulated during backtests.
Backtesting may affect the future performance of a trade. While some traders may decide to manually backtest, though it will be a longer, slower process. Other traders will codify their strategy and run it against a robust historical data set. Ideally, the best way to backtest a crypto strategy is via systems test using order book data. Still, the wild crypto market is unpredictable.
Using a backtesting tool or software is excellent to help track your trading strategy and help to formulate the most optimal cryptocurrency trading strategy that eventually leads to a better risk-adjusted return. Still, crypto is volatile, and we recommend you seek professional advice before live trading.