Introduction to Backtesting Strategies
Backtesting is simply the process of testing a trading strategy using historical data so that a trader can see whether his/her strategy has a statistically profitable edge. How to backtest a trading strategy is a vital step that any trader should go through in order to know whether they stand a real chance of making money in the markets.
When a proper backtest delivers good results it also helps a trader to gain confidence in that strategy, which is a huge psychological step in the right direction because confidence helps control the negative emotional aspects that can come with trading.
In this article, we will have a look at the best practices necessary to backtest a strategy properly and the pitfalls that should be avoided in order to achieve the most reliable results possible.
What Is Backtesting?
Backtesting is an essential component of effective trading. It includes restructuring trades that could have been completed in the past using rules derived from existing strategies. The results of this analysis allow traders to estimate the strategy’s effectiveness.
The underlying theory for backtesting is that successful strategies of the past are bound to work in the future. Thus, strategies that failed in the past are doomed to fail again.
Why Do You Need to Backtest Your Testing Strategy?
Backtesting provides traders with critical information to analyze their current trading strategy. As the saying goes, “history repeats itself.” Backtesting puts the old adage to test, helping traders analyze risk and profitability before committing to a trading strategy.
Backtesting that yields positive results provides evidence and assurance for traders that their strategy is sound while negative returns cause them to question the validity of their strategy.
What Does Backtesting Tell You?
As long as you can qualify and quantify your trading strategy, you can backtest it. Traders may want to enlist the help of programmers to ensure proper data input, which typically entails them coding a strategy into a trading platform-hosted proprietary language.
Programmers can include user-defined input variables that make it easier for the trader to modify the system. In these models, traders can change the moving average intervals and determine which moving average durations performed the best in the past.
What Do You Need Before Backtesting Your Trading Strategy?
Before backtesting your trading strategy, you need to develop a trading plan. Trading plans answer critical questions so you can more accurately understand backtesting data. The last thing you want to do is try to backtest your trading strategy while still asking yourself the following questions:
- Where are my trade entry points?
- Where are my trade exit points?
- Should I set a stop loss?
So, before you think about backtesting your trading strategy, make sure you have one first. You can use the following questions to ensure the completeness of your trading strategy.
- How much risk can you tolerate per trade?
- What are your trading timeframes?
- What are your trading entry points?
- Where are you going to set you?
After answering these questions, it’s time to decide how you want to backtest your trading strategy. There are ways to backtest your trading strategy if you have nor formal coding trading. However, using a programmer with experience will streamline your backtesting and give you access to more data. It will also make it easier for you to control the backtesting data output.
Backtesting Trading Strategies: Best Practices
Trading should first and foremost be treated as a business. Your trading strategy is like your plan on how to make money for your business. A strategy is therefore one of the most important components of your business and should be given the necessary time and commitment needed to prove its worth.
Before we look at the best practices for backtesting a strategy it’s worth examining the two types of backtesting: automated backtesting and manual backtesting.
Using software to automatically backtest trading strategies can save a lot of time and allows a trader the ability to test multiple markets or time frames very quickly. In order for the software to backtest a strategy, a trader would need some degree of programming or coding skills if they want to do it correctly which may be a drawback for most people.
Manual backtesting on the other hand does take more time because you need to manually find and log historical trade setups but doing just that is a great way to learn more about your strategy and to gain confidence in it. It is definitely an exercise well worth doing when done right.
Moving forward we will focus on manual backtesting and the best practices for doing it correctly.
1. Use a large enough sample size of historical data to backtest with.
The chart above shows 1 year of data on a 4-hour chart of Crude Oil. Backtesting a strategy properly requires at least one year of historical data to test it on and it’s always a good idea to test multiple markets as well.
My strategy requires that I trade the end of corrections within a trend. There are many techniques that I use to do this but on the chart, I used simple trend lines to determine a change in trend and what the current trend is. The black boxes are corrections that my strategy identified and show past tradable opportunities.
2. Know what your strategy rules are and follow them.
The most recent correction in my sample was an actual trade that I took and planned to trade in advance.
To find the end of corrections I first need to identify which correction could be underway in real time and use market geometry techniques to identify where that correction is most likely to end.
Note that the chart above was a screenshot of where I planned to enter a position to go long.
The price of Crude Oil had other plans on the day and fell right through my original entry zone, which prompted me to look for an alternative entry a bit lower.
Following a set of entry conditions, which are rules-based, I did not have a valid entry signal within my entry zone which moved my focus to find a secondary entry. I got that entry after a minor triangle correction appeared on my 5-minute entry chart (results to follow later).
3. Test your strategy in all market conditions.
It is important to note that market conditions change all the time and that you should test your strategy in both trending and corrective phases. My strategy requires that I identify a trend and trade the end of a correction which makes my strategy particularly useful in all market conditions.
4. Log your results (good or bad).
Not all trades always work out. Sometimes you will have losses while at other times you may miss a trade. On this trade setup, I had three targets that were met over the course of more than 24h and the results were great. Keeping a journal is a good way to log your backtest results and should include both the trades that would have worked out and those that did not.
Remember that when you backtest your results assume that you were actually there to have taken that trade. So an important thing to consider when backtesting is logging results during the times you would most likely have been present to trade.
The chart above is that of Wheat, and it was a trade I have been following for a while and which I missed a setup on.
Although price made it into my entry zone it missed my lower blue market geometry line which is a crucial part of my strategy rules which caused me to miss that trade. If this setup was part of my backtesting, I would not have been allowed to log that trade. Remember honesty is the best policy.
Just look at that powerful movement out of that low. Even though I correctly identified what could happen, I never had a setup.
5. Note all the metrics of your strategy’s performance.
After you have backtested your strategy against a decent amount of historical price action there should be a clear indication as to whether you actually made a profit or a loss. Other important metrics to consider are:
- Did you experience a drawdown and how long did it last?
- What was your average win/loss ratio?
- What was your average risk vs. reward ratio?
- The largest amount of winning trades in a row and the same with your losing trades.
It is important that you know that the performance of your strategy may look great on paper but it does not account for your emotions when it becomes time to trade actual money in a live trading environment where you cannot see the future.
You may therefore have to allow for a drop in the strategy’s performance of around 5 – 10% when you actually go live.
6. Consider whether your strategy requires tweaking or needs to be scrapped.
If you have been honest about your strategy’s results and they end up not looking that great then it may be time to tweak your strategy or scrap it and start over again. A big mistake that traders tend to make is that they change their strategy rules (or add more rules to it), while they are backtesting, thinking that they can improve its performance.
This will lead to unreliable skewed results, so if you need to tweak your strategy then do it before you start backtesting again and not during testing.
Sometimes the best thing to do is simply scrap a strategy entirely if it fails to produce the desired results. Proper backtesting will take a lot of your time and if the results are not good you may need to go back to the drawing board and come up with a new approach. This is often better than trying to save a strategy that has no edge. Knowing when you are wrong is an important part of trading and those who cannot accept being wrong about their ideas will get crushed in the markets.
7. Test your strategy in a simulated account
When you do arrive at a strategy that has potential the next important step should be to test it in a real-time environment but in a simulated account. Trading with real money right off the bat is not a good idea and brings a whole host of emotions with it that can undermine your performance.
I honestly believe that if you cannot make money in a simulated account first, then you will surely not be able to make it in a real money account either. You need to allow yourself the time to prove the profitability of your strategy without any real risk. This will give you that added confidence that you will need when you are ready to go live.
Consistency in trading is very important and is why most successful traders took months or even years to develop, backtest and trade their strategies in a simulation account before they go live.
The entire process of backtesting is an important step for those traders who wish to develop their own strategies and have the pleasure of seeing their hard work pay off in the end. Some traders however do not have the time to go through this process and may seek to purchase a proven strategy instead.
The problem with buying such a strategy is that they can be hard to find and even then the success of that strategy relies on the level of commitment that a trader places in understanding that strategy. Allowing yourself enough time to become confident in a strategy’s ability and your own to execute it properly is a crucial part of a trader’s development process. If you would like to know more about how all of this can be achieved then be sure to check out my Trade Forecasts, here.
Backtesting trading strategies and knowing how to backtest a trading strategy properly is an important part of any trader’s success and I would recommend it to anyone who wishes to put their own trading plan to the test.
Until next time,
All the best.