“Probability is not a mere computation of odds on the dice or more complicated variants; it is the acceptance of the lack of certainty in our knowledge and the development of methods for dealing with our ignorance.”
― Nassim Nicholas Taleb, Fooled by Randomness: The Hidden Role of Chance in Life and in the Markets
Algorithmic trading comes down to coming up with a set of rules to manage risk in the face of uncertainty.
There are 2 ways to test a trading strategy. Using historical data to run simulations or trading it live in the market. Backtests are used by many quants and hedge funds in their strategy development process. Backtesting your strategy allows you to study a large sample of trades for statistical significance to come up with a robust system before putting capital at risk.
In this article I want to cover 7 common pitfalls to avoid when developing your algorithmic trading strategy. Past performance is not indicative of future results.
An overfit strategy is one that performs very well on backtested data, but poorly in live trading or forward testing. This can happen when many system parameters are used leading to a strategy that is likely fitted to past market noise opposed to an underlying inefficiency or sound theory.
Increasing the number of parameters or indicators used in your strategy will increase the degrees of freedom of your strategy, leading to a higher probability of overfitting in backtesting. This is why many of the algorithmic traders I’ve learned from over the years have stressed using simple and robust strategies. The more degrees of freedom you have in your system, the more likely your system is able to fit itself to the past data series during optimization.
The best way to gain perspective on this is to test out different strategies with varying numbers of parameters. It took me a long time to settle on a simple strategy and it ultimately came down to running hundreds of backtests and studying the results.
Good backtest results for a strategy are usually eye-grabbing, but this doesn’t mean you should immediately put funds at risk for the strategy. You should always be very skeptical of the results you are getting and try to find errors in your assumptions and reasons why the results should be invalid.
If you can test and think of every possible way in which your strategy, assumptions or backtest could be wrong and the results are still eye-popping, then you just might have a robust strategy.
However, always lurking is the chance of an extreme scenario unaccounted for in your backtesting like the one day 8,000 point drop in the S&P 500 in October of 1987 or the 40% move in EURCHF minutes after the SNB abandoned the peg without notice.
You may be tempted to trade your strategy with as much risk and leverage as possible to capitalize on your discovery. If so, don’t forget about the market examples above.
3. Don’t Override Your Strategy
I’m all for doing research to enhance your strategy, but you can get into trouble if you override your strategy in the heat of the moment. This is a very common urge for systematic traders.
Humans are prone to making emotional decisions and decision fatigue alone can lead to poor decisions. At some point, you’re likely going to make a poor decision due to fatigue alone.
If you’re constantly second guessing your live strategy and manually intervening, beware that many factors can influence your decisions. A data-driven, researched approach to implementing changes is likely a better approach. Most people decide to trust their risk management process to avoid issues like decision fatigue, emotional trading and relying on hunches.
4. Backtesting short duration strategy with 1 min data
If your strategy holds trades for a short duration like minutes or uses tight stop and limit values, you will want to be as precise as possible when backtesting and use high quality tick data. There may be upwards of hundreds of ticks in a 1 min bar and many assumptions will be made if you’re not being as granular as possible in your backtests.
If you’re not sure what to do, you can run a comparison test using ticks and 1 min bars. If there is a noticeable difference in results, you will likely want to use tick data for your testing. Just note that a backtest using ticks will require a lot of memory and may take a long time depending on your setup.
5. Use Incorrect Transaction Cost Assumptions
Some strategies are highly sensitive to transaction costs. Likewise, some strategies can appear to literally print money if you are not accounting for the spread or commissions in your backtests. Failing to account for items such as commissions or reasonable assumptions on slippage can severely distort a strategy's performance.
6. Optimize Parameters Over Entire Data-set
If you’re optimizing parameters over your entire dataset, you will increase your chances of overfitting your strategy to that particular time series and will have to test strategy robustness on live trading. Saving a portion, say a 1/3 of your data history, for out of sample testing will allow you to implement walk forward testing and see if performance numbers are close to your backtests. Additionally, you can also randomize the order of the data history to avoid risks of overfitting during strategy optimization.
7. Cherry Pick Markets
The urge to settle on one particular market based on great backtests can lead to wishful thinking. Your goal should be to find all the ways in which your strategy or assumptions may be biased. If your strategy performs great on EURUSD for example but hemorrhages money on GBPUSD, think about why that may be the case. Adding additional markets with an effective strategy can possibly reduce the overall volatility of the account if each market is profitable. Strategies that are highly sensitive to market choice may indicate overfitting or randomness.
Be careful to not delude yourself with the idea of easy money. Your algo strategy will be the result of your best efforts to systematically control and diversify risk in the face of an uncertain future. Once you have a strategy you’re ready to automate, you still have to have the emotional fortitude to ride through the inevitable ups and downs, avoid self-sabotage, and make decisions regarding your strategy from a position of uncertainty that will never disappear.
Algorithmic trading to me is the result of taking everything you know about the markets and coming up with a trading approach that can be clearly defined down to each component which allows you to backtest and optimize the parameters. Many traders never get past the first step and just make trading decisions based on hunches. However, if you can do the research, come up with an idea for a strategy and then backtest it, you can gain a great deal of insights about your strategy before risking a dime.