Last week we reviewed the different steps needed to become an algorithm developer. This week, we'll focus on the next step, testing your strategy. Let's go!
What is backtesting?
You already know that developing a strategy is more difficult than learning to code. When you have a potential business idea, backtesting becomes useful.
Backtesting, as the name suggests, involves traveling back in time to see how your algorithm would have performed given past market data. Of course, this does not ensure that your plan will continue to be effective in the future, but it is an excellent place to start.
Backtesting Don’t
Overfitting
Let's begin by saying what to avoid doing. Making a strategy as straightforward as possible and then optimizing it to the point where it performs well on your historical data set is quite simple. Sadly, nothing could be further from the truth than this!
As was already mentioned, this phenomenon is known as overfitting and involves over-optimizing your parameters on a fixed data set. The typical result of this type of exercise is that your strategy completely fails when you come into contact with the real market.
Look-ahead Bias
This is also a little bit of an overfit, but in a different way. It will be more difficult to develop a strategy that works on BTC on shorter timeframes because the changes are more irregular. Since they are less predictable, only a sophisticated and reliable algorithm will be able to handle them.
On the other hand, if you want to develop a trend following strategy based on daily bitcoin data, the outcomes will probably be favorable even if you divide your training and testing periods because you are aware that BTC has been trending upward from its beginning. The look-ahead bias is evident here.
Backtesting Do
Let's now go on to the necessary tasks! The first step is to decide which trading pair or assets you wish to test because the outcomes of one trading method are not always transferable to another. Next, select your reference timeframe, and everything should remain in place after that.
In and out of the sample
Now we will divide our historical data set into two sections, which will help us avoid overfitting. If the data for a strategy spans four years, we will divide it as follows: One year for the Out sample and three years of data will make up the In sample.
Then, depending on the first three years, we will optimize all of our parameters in an effort to maximize prospective profit, success rate, and minimize maximum drawdown.
When we obtain a satisfying outcome, it is time to validate it on the remaining sample to see if the strategy's behavior is consistent. If it is, your algorithm has a decent possibility of being able to profit from the market. The last phase is to scale up after testing your technique in actual market circumstances with a limited amount.
Conclusion
Now you know how to avoid getting into a bad situation in the markets with backtesting.
Next week, we will discuss something different, grid trading!.
Do you already have a trading algorithm working, or even know someone having a good one? Do you want to earn passive income by renting it to one of the best trading communities and be sure to get what you deserve? If you answer yes to this, we invite you to contact us : [email protected]