Home Creators Posts Import Register Favorites Logout

Content

Introduction

This is a follow up on my previous blog post on “Backtesting Pitfalls to Avoid: Lessons Learned from Real-World Trading”. I will mention these pitfalls but will not go deep into these in this post since each subject deserves its own post to describe these more in depth.
And as experienced traders in the realm of algorithmic trading, you might have already witnessed the power and complexities of backtesting. Backtesting is an indispensable tool that allows you to test your trading strategies against historical data, providing insights into their potential performance. However, the journey to success is riddled with various pitfalls that can trip up even the most seasoned traders. In this comprehensive guide, we will explore an extensive range of backtesting pitfalls that demand your attention and provide essential insights to elevate your trading endeavors to new heights.

Understanding the Impact of Survivorship Bias

As veteran traders, you are well aware of the survivorship bias that can taint backtest results. In your journey, you may have encountered strategies that performed admirably during backtesting, only to disappoint in real-world trading. The exclusion of unsuccessful assets or strategies from the backtesting process can create an illusion of success that fails to hold up when faced with the full spectrum of market conditions.

To overcome survivorship bias, consider incorporating a more comprehensive dataset that includes assets and strategies that experienced both success and failure. By learning from past failures, you gain valuable insights that can shape a more robust and adaptable trading approach. This is the reason that I use at least 50 pairs in my backtesting. The pairs ratio tells me if a strategy has the potential to be applicable to “all” crypto assets. But ofcourse you have to test this on your own specific set of preferred pairs also.

Mastering Risk Management

Risk management remains the cornerstone of successful trading, and advanced traders understand its paramount importance. In backtesting, it’s crucial to go beyond merely testing for profitability and also assess the risk inherent in your strategies.

Integrate advanced risk management techniques, such as stress testing, Monte Carlo simulation, and scenario analysis, to evaluate the resilience of your strategies under various adverse conditions. By factoring in realistic risk measures during backtesting, you’ll gain a deeper understanding of the potential drawdowns and risks associated with your trading strategies.

In my tests I do not have these (yet?) since the backtesting engine does not provide this. However once it will, i will certainly apply this to my own tests.

Unveiling the Impact of Transaction Costs

Seasoned traders recognize that real-world trading involves transaction costs, slippage, and liquidity considerations that significantly influence profitability. In advanced backtesting, it’s vital to account for these factors to create a more accurate representation of your trading strategy’s performance.

Incorporate realistic transaction costs and slippage models to refine your backtest results and align them with the realities of live trading. By doing so, you’ll gain a clearer understanding of the expected returns and make more informed decisions when deploying your strategies in real markets.

Tackling Overfitting with Robust Optimization Techniques

The allure of overfitting often tempts even experienced traders, leading to strategies that are excessively tailored to historical data but lack adaptability in live markets. To navigate this treacherous terrain, embrace robust optimization techniques that strike a balance between historical performance and the ability to generalize to new market conditions.

Utilize methods like cross-validation, walk-forward optimization, and out-of-sample testing to gauge the performance of your strategies under different scenarios. By ensuring that your strategies remain versatile and resilient, you can reduce the risk of overfitting and maintain a competitive edge in the dynamic world of algorithmic trading.

In my video’s I always warn about overfitting. Especially when of after hyperoptimizing the parameters, ROI, Stop loss and other things of the algorithms code. It is nice to see the potential of an algorithm but you always have to keep in mind that these performances have no future guarantee.

Addressing Behavioral Biases

As experienced traders, you understand the psychological challenges that accompany trading. Behavioral biases, such as confirmation bias and hindsight bias, can influence your approach to backtesting and lead to suboptimal results.

Stay vigilant of these biases, and strive for objectivity in your backtesting process. Maintain a disciplined approach and resist the temptation to cherry-pick data or manipulate parameters to fit preconceived notions. A keen awareness of behavioral biases will enable you to make more objective and data-driven decisions throughout your trading journey.

Look-Ahead Bias and its Pitfalls

While not explicitly mentioned in the previous post, look-ahead bias is a significant concern in backtesting. It arises when future information is unintentionally used during the testing process, leading to unrealistically favorable results. To avoid look-ahead bias, ensure that your backtesting methodology strictly adheres to using only historical data that was available at the time of testing.

According to the backtest engine documentation:

Checking look ahead bias is the bane of any strategy since it is sometimes very easy to introduce backtest bias – but very hard to detect.

Backtesting initializes all timestamps at once and calculates all indicators in the beginning. This means that if your indicators or entry/exit signals could look into future candles and falsify your backtest.

Lookahead-analysis requires historic data to be available. 

This command is built upon backtesting since it internally chains backtests and pokes at the strategy to provoke it to show look ahead bias. This is done by not looking at the strategy itself – but at the results it returned. The results are things like changed indicator-values and moved entries/exits compared to the full backtest.

You can use commands of Backtesting. It also supports the lookahead-analysis of freqai strategies.

--cache is forced to “none”.

--max-open-trades is forced to be at least equal to the number of pairs.

--dry-run-wallet is forced to be basically infinite.

Conquering Data Snooping Bias

Data snooping bias can be a subtle pitfall in backtesting, as multiple variations of a strategy may be tested, and only the best-performing version is selected for further analysis. This cherry-picking can lead to inflated expectations and poor performance in live trading. To address data snooping bias, establish a clear protocol for selecting and testing strategy variations and maintain strict discipline in adhering to the chosen approach.

Navigating Time Period Bias

Time period bias can significantly impact backtest results, as different market conditions may prevail during various time periods. To tackle this bias, consider conducting sensitivity analysis by testing your strategies across multiple time periods to gain insights into their performance under diverse market conditions.

In my tests I simply use all the data I get from the exchange to test over. This way I can ‘experience’ multiple bear markets in my tests to see how a strategy performs during these periods.

Embracing Sample Size Considerations

The size of the historical dataset can influence backtest results. Sample size bias can arise when there is insufficient data to provide statistically significant insights. To mitigate this bias, ensure that your historical dataset is sufficiently large and representative of a wide range of market conditions.

See previous point here…

Understanding Market Impact Bias

While transaction costs and slippage were discussed in the previous story, the specific bias related to market impact when scaling up positions is also crucial. As you deploy your strategies in live markets, keep in mind the potential market impact of large trades and adapt your approach accordingly.

Therefore you always have to plan a period in which you will test an algorithm under ‘semi’ live market circumstances with a ‘dry run’.

Guarding Against Curve Fitting Bias

Curve fitting bias can be a tempting trap for traders as they aim to optimize their strategies for historical data. However, overly tailored strategies may fail to perform well in new market conditions. To guard against curve fitting bias, prioritize robustness and flexibility in your trading strategies, allowing them to adapt to changing market dynamics.

Finally

As experienced traders seeking to elevate your algorithmic trading game, navigating a comprehensive set of backtesting pitfalls is a crucial endeavor. By understanding and addressing survivorship bias, mastering risk management, accounting for transaction costs, tackling overfitting, and being mindful of various biases, you can create a more robust and resilient trading approach. Remember that trading is a dynamic journey of continuous learning, adaptation, and improvement. Embrace these lessons from advanced backtesting, and you’ll be better equipped to conquer the challenges and reap the rewards of the ever-evolving world of algorithmic trading.

I hope you will find the perfect trading strategy algorithm which brings you much fortune.

Comments

SLZ

Thank you for your insight, I noted sometimes big differences between dry-mode and back testing, I still need to analyse, but quick question if you have time, did you already run dry mode and real mode simultaneously, and so did you notice big differences? Anyway thank you for sharing your knowledge, very appreciated

Dutch Algotrading

Hi SLZ, No I did not since my Dry mode journey only started a couple of weeks (months) ago. Personally I'll use the strategy that has positive results only after 6 months or running. Some consider this short ans some long - so this is a personal thing here. Besides that I'm only a long time investor and manual trader (hence the testing of "manual strategies" too). So I do have skin in the game. Hope this information helps.

Dominic Isaiah

Hi, I just joined your patreon and let me know where to start please. Is there a beginners guide?

Dutch Algotrading

Hi Dominic, Start with the creation of the bot and build your own strategy posts and video's. And then gradually work your way up from there. It is a long but satisfying journey. Don't hesitate to ask questions :-)