What Is Overfitting in Systematic Trading?
Overfitting is one of the main things you need to watch out for when you’re developing trading strategies.
It’s a term some of you might already know, while for others it may be completely new.
If we had to define it in simple terms, we can say it’s a modeling error in strategy development, where you end up fitting your model too closely to past data.
When you make this mistake, you usually get great results during the testing phase, but very poor ability to interpret future data, and therefore to generate profits on data you haven’t seen yet.
In this video, we’re definitely going to go deeper into this topic.
But first of all, one key thing to understand right away is that we need to put our ego aside.
Instead of thinking, “Look how smart I was building this strategy on past data,” we need to force ourselves to build something that can actually work going forward.
Maybe it won’t have a beautiful equity line, but what really matters is that it has some level of predictive value for the future.
At this point, I’d say we can switch to the screen and go a bit deeper into these concepts, also by looking at some examples.
So let’s dive a little deeper into the concept of overfitting, starting from a simple question.
Trading Backtests: Why Results Can Be Misleading
Let’s assume we’ve developed a strategy using MultiCharts on one of our favorite instruments.
And we’ve used several years of historical data, for example starting from 2010, which is what we typically do for most strategies.
Now, let’s say we’re using an indicator.
By running an optimization, we might notice that some parameter values work better than others for that indicator, and that the best results are achieved using a specific value, let’s call it X.
Alright, but is that value X really going to be the best one in the future?
Let me give you an example from everyday life.
Here I pulled the league results of Real Madrid.
Yes, I know this example might not be everyone’s favorite, especially if you’re a Barcelona fan.
But what we can see is that from the 2006-2007 season all the way to the most recent one, Real Madrid has often finished in first place.
Sometimes second, sometimes third. Then back to first, and so on.
So naturally, what we tend to think is that since it’s a strong team, it will most likely finish first, second, or third again next season.
Or at least, not too far from those positions.
This is just a soccer example, but the exact same idea applies to any other sport.
Take Formula 1 drivers or teams. Usually, the best team this year won’t suddenly perform terribly next year.
Or think about Mr. Olympia competitors who dominate for several years in a row, and so on.
Why Financial Markets Are Different from the Real World
But now let me ask you a different question.
Does this same logic apply to financial markets?
What I tried to do is answer that with this slide.
Here we tested the Donchian Channel, which is a trading indicator, from 2010 to 2025.
I optimized the period between 5 and 20, selecting the best one based on net profit over drawdown, and then checked what the best period would have been for each year.
Now, one thing we can already notice is that there’s a lot of variability.
For example, in 2010 the best result in terms of net profit over drawdown would have been achieved using a 13-period Donchian Channel.
In 2016, it was a different period. In 2019, it was 17 periods, and so on.
There’s no single value that consistently works year after year.
So what’s the key takeaway from this?
As I mentioned earlier, we’re used to thinking that today’s top performer will also be tomorrow’s top performer.
And that’s often true in everyday life, unless something changes or unexpected events come into play.
Think about an athlete getting sick, a controversial championship outcome, or something like that.
In financial markets, things don’t work exactly the same way, because there are so many variables that can influence the market.
Just think about interest rates, wars, inflation, new regulations, and so on.
The point is that financial markets are inherently driven by a certain degree of randomness that we simply can’t fully capture.
How to Avoid Overfitting in Trading Systems
So what could be a possible solution?
One possible approach is to rely as little as possible on specific parameters or inputs of a strategy, and instead put more weight on the underlying concept you’re trading.
We’ll make this clearer with an example, because said like this it might sound a bit abstract.
What I’m trying to explain is that if a strategy works with a 20-period Donchian Channel, and it also works with 22 periods and with 18 periods, then what really matters is that trend following tends to work on that instrument.
Not that the strategy works because you used that exact parameter.
And this is very important.
So as I mentioned before, let’s look at an example.
Practical Trading Strategy Example on MultiCharts
Here we are, as usual, in the MultiCharts Power Language Editor, and here I’m showing you a simple strategy.
This strategy uses a pattern on a daily timeframe and enters trades on a lower intraday timeframe, for example five minutes, based on that pattern.
More specifically, we enter trades if we have a candle showing indecision, which in this case I defined like this:
If the body of the daily candle is less than 25 percent of the total range of that candle, then we’re likely dealing with a condition of indecision.
In other words, imagine price moved a lot during the session, but the actual difference between open and close is relatively small.
If this condition shows up on the daily timeframe, then on the following day I’ll open a long position on a breakout above the previous session’s high, and a short position on a breakout below the previous session’s low.
Here I didn’t set a stop loss or a take profit.
For the long position, I simply exit if price goes back to the session’s opening level.
So basically, if there’s been a breakout, but it’s not really going anywhere and price is pulling back, I close the long position.
Same thing on the short side: if price goes back to the opening level, I close the short position as well.
As for other exit rules, I use a set exit on close command, so we exit at the last traded price of the session.
Now let’s see how this strategy performs on a fairly diversified portfolio.
Testing a Strategy on a Diversified Portfolio
I tried to include a variety of different instruments.
For example, we have the mini S&P 500 futures, the DAX, copper, and gold. I included these two metals because gold has shown a strong trend-following behavior in recent years.
On the other hand, copper has been more mean-reverting, with prices tending to move back toward average levels after reaching certain extremes.
Then we have crude oil and natural gas to include some energy markets, and other commodities like soybeans, lean hogs, plus the euro-dollar futures to also include a currency market, mainly for diversification purposes.
Alright, so let’s see how this strategy performs. And here are the results across the whole portfolio.
First of all, I want to point out two things.
The first is that these results don’t include commissions, slippage, or anything like that, because that’s not what I’m focusing on right now.
Most likely, across many instruments, the average trade wouldn’t be large enough to make this strategy viable in live trading, especially considering it’s an intraday strategy, which usually captures relatively small moves.
What I care about here is evaluating whether this simple concept can work across a fairly diversified portfolio.
The second important thing to notice is that in the most recent period, this portfolio performed very, very well.
But I also want to point out that these strong results are most likely driven by gold futures, which had a particularly explosive move.
So it’s not that the strategy performed incredibly well across all instruments.
That said, let’s take a look at some specific results.
For example, even without considering slippage and commissions, this strategy would have generated profits across all instruments.
Let’s take crude oil as an example. Here we can see an equity curve that’s not as smooth as the overall portfolio curve.
That’s expected, because the goal of a portfolio is to smooth out drawdowns.
But overall, it’s still an upward-sloping equity curve, despite the simplicity of the strategy.
Now let’s look at natural gas.
Here as well we see a pretty solid curve.
Or let’s take another example, like the euro-dollar futures.
Typically, that’s a more mean-reverting market, and in recent years it’s been quite challenging from a systematic trading perspective.
And yet here we see that this strategy doesn’t perform that badly, even though, again, it’s being applied to a market that might not be ideal for this type of logic.
Is This Strategy Really Overfitting?
So at this point, what can we say about this strategy?
Is it overfitted?
Well, honestly, it’s actually hard to even find a parameter here that could be overfitted.
Someone might say the 0.25 threshold for the candle body.
But I can tell you that if you set it to 0.20 or 0.30, the strategy performs just as well.
In fact, as you can see, I didn’t even include it as an input to optimize. I simply used the concept that it should be less than a quarter of the total range.
And as you can see, I’m focusing more on the concept itself.
What am I actually trying to capture?
A phase of indecision, of uncertainty, defined by this pattern, after which I expect a meaningful move either up or down.
The reason the strategy works is not because I used some precise value like 78.26 on the Donchian Channel, combined with a moving average calculated over a very specific number of periods, with some crossover or other complicated stuff like that.
It’s because I’m using a simple idea that captures how the market behaves.
Now let’s go back to the slides, because there’s another interesting example to look at.
Here we are.
The Most Important Rule for Building Robust Strategies
Another extremely important aspect, beyond what we’ve just seen, is to always use common sense when developing a strategy.
As I said at the beginning of the video, it’s essential to set your ego aside.
I’m not interested in building a strategy that looks as good as possible on past data.
I want to create something that has the highest probability of lasting in the future.
My goal is not to come up with ten spectacular strategies, but if I do develop ten strategies, I want most of them to give me results going forward.
Even if those results aren’t amazing or beautiful or anything like that, they need to survive in the future.
Otherwise, we’re basically just playing with data.
With that said, let’s analyze this example.
Trend Following Test on S&P 500 and Nasdaq
Here I took another trend-following strategy, one of mine, just to give you an example.
Because in my opinion, this is a concept that is often taken for granted and not explored deeply enough, but it’s actually a great reality check to understand whether we’re dealing with overfitting or not.
Here you see, again, a trend-following strategy.
And you see it applied to S&P 500 futures and Nasdaq futures.
I set the initial capital for the backtest at 1,000,000 dollars for both, just to make the comparison more consistent, but that’s not really the key point here.
So what can we say about this strategy?
We can say that it works on S&P 500 futures, and maybe it works even better on Nasdaq futures.
Of course, I’s expect some differences, because these two instruments are quite different.
We know that the Nasdaq is generally more explosive and is made up of 100 tech companies, while the S&P 500 is broader, with 500 of the largest companies.
So it’s normal to see differences, for example in the most recent period where both curves pull back, even though the S&P pulls back a bit more.
Or where we see a sideways phase with some drawdown that appears less pronounced on the Nasdaq.
How to Recognize a Real Statistical Edge in the Markets
But the key point is this: if a strategy works on one instrument but not on another, then we’re probably not capturing a real edge.
Instead, we’ve adapted our rules to a specific historical series.
In other words, if the strategy more or less works on both instruments, that’s a good sign that we’re capturing something that generally works on stock indices.
But if we have a great equity line on S&P 500 futures and a flat or even losing strategy on Nasdaq futures, then what does that mean, based on the definition we gave at the beginning?
It most likely means we’ve overfitted.
Because if the strategy doesn’t work broadly across stock indices but only fits one specific dataset, that’s basically the textbook definition of fitting a historical series.
How to Understand if a Trading Strategy Is Too Complex
To wrap things up, as I mentioned earlier, I want to emphasize that strategies should be as simple as possible.
And the main goal is to understand markets in a broader sense, so that strategies can also work in the future.
The way I personally evaluate whether a strategy is too complex is by asking myself a simple question:
If I were just looking at the price chart, would I be able to understand if and when the strategy is entering a position?
If the answer is yes, then it’s a very simple system, clearly based on a limited number of rules.
If the answer is no, because the strategy depends on the crossover of six indicators, eight different patterns, and other conditions that I might not even fully understand why I included, then it’s probably too complex and unlikely to last in live trading.
Of course, by doing this we won’t be able to build a new system every minute.
We need to be more selective and develop a deeper understanding of the markets.
But if you want to trade professionally, this is the best path to follow.





