How to Avoid Overfitting / Curvefitting in Trading


What is Overfitting?

 

Overfitting (or curvefitting) is when you tweak settings in your strategy and try to find the perfect settings for a profitable setup in backtest data. This is a very common practice on Tradingview, but unfortunately, creates unrealistic profit graphs.

 

How do you know if you've overfitted?

 

There are a number of ways to identify if you've overfitted your strategy.

 

  • Your strategy thesis is not profitable until you tweak values in the strategy

 

  • Your strategy is only profitable on the time period you tested on and when going into Bar Replay mode and checking past data, your strategy fails

 

  • You don't understand why you're changing the values you're changing, you're just tweaking values at random to find the best backtest results

 

  • You've used a third-party application to "optimize" your strategy settings

 

How to avoid overfitting

 

  • If you've found a "sweet spot", this is not overfitting, necessarily. For instance, if you change a value from 74 to 75 in the strategy and the strategy is slightly more profitable but still profitable at both values, this is a sweet spot, not overfitting

 

  • Use the Bar Replay mode, go to the first bar and click on it. When the past data loads, if your thesis is good, you would expect the strategy to still be roughly as profitable in this past period. If it isn't, you might have overfitted.

 

  • Any time you change a value in your strategies, it should be motivated by your thesis. For instance, perhaps you use a 40 crossing point for an ADX, as this represents a strong trend. Your thesis is consistent with a higher value crossing point as this would be a stronger trend in the market.

 

  • Don't use third-party applications on Tradingview to optimize a strategy. These tools are overfitting tools, and will not make you more money. Moreover, the use of these tools is against Tradingview Terms of Service and may result in your account being banned.


Leave a comment