LUCKY DOGSTRADING SYSTEMS
Sign in
All news
ArticlePublished · 12 min read

Overfitting in trading: 7 signs your EA fits only the past

By · Founder of Lucky Dogs Trading Systems

Overfitting in trading: the perfect curve in the test and the drop out of sample

Overfitting in trading is when a robot (or a strategy) is fitted too closely to the past: instead of finding a rule that repeats, it memorizes the noise of the history. In the test, the curve is perfect. On the account, the result disappears.

You know the scene. After an afternoon tweaking parameters, the curve finally climbs smooth, from left to right, without a single bad month. Or it shows up ready-made, on the page of someone who is selling. The urge is to switch the robot on right away.

The problem is that, with enough adjustments, any history turns into profit. Whoever tests a thousand combinations and keeps the best one has almost always picked the luckiest. And luck doesn't repeat next month.

The rule that separates the two fits in one sentence: a result only counts on data that didn't help choose it.

What is overfitting in trading (and what is curve fitting)

Overfitting is a rule that fits the past so well that it stops being useful for the future. It didn't learn the market: it learned that history, with its flukes.

A simple example. A rule buys gold when a short moving average crosses above a long one. It wins in some months and loses in others. To remove the losses, you add a time-of-day filter. Then another, which skips Mondays. Then a third, which ignores days with a wide spread.

In the end, the rule gets almost every day of the history right, because each filter was built to erase one specific bad day. Those days don't come back the same way, and the rule loses its footing.

The names change, the idea is the same:

  • curve fitting is adjusting the curve: tweaking the parameters until the equity curve looks good;
  • over-optimization is what traders call it when the tweaking came out of the optimizer;
  • in machine learning, overfitting is a model that memorizes the training data and misses on new data. It is the same concept, which is why searches for it mix trading and artificial intelligence.

The opposite is underfitting: a rule too simple to catch anything, even in the past (more in the FAQ).

Why testing a thousand combinations manufactures a perfect robot

Take a thousand coins and flip each one ten times. It is quite likely that one of them lands ten heads in a row. It isn't a better coin: it is the luckiest of a thousand. Flip it again and it goes back to heads and tails like any other.

Testing a thousand combinations of parameters and keeping the best one is the same draw. Each combination is a coin: the one on top may have a real rule or just the right flukes in that history. Only a test on new data tells one from the other.

The best of a thousand combinations in the test tends to fall back to the average out of sample
The luckiest of a thousand is not the best.

Three things raise the champion's luck:

  • More parameters. Each extra adjustment is one more way to fit the past.
  • More values tested for each parameter. A thousand combinations have more luck to offer than ten.
  • The noise in the history. A piece of news, a Monday gap, a day when gold moved twice as much as usual. The winning combination is usually the one that got those flukes right, and they don't repeat on the same date or in the same way.

MetaTrader 5 has a tool built for this problem: the forward of the Strategy Tester holds back a piece of the end of the period that the optimization doesn't see. The combination chosen at the start is checked on that piece. It is the coin flipped again. Don't choose by the result in the "Forward" tab: it only checks.

The 7 signs of overfitting in a robot

No single sign proves overfitting; together, they tell the story. Each one comes with a way to check it.

  1. The curve is perfect. Years of history without a bad month and without a losing streak. A real market has bad months. How to check: the result month by month, not just the total. A smooth curve is also the portrait of martingale, which bundles small losses into one big one and saves it for the worst day: see the martingale strategy and how to spot it in a robot.
  2. Many parameters for few trades. Dozens of adjustments and a few dozen trades. With so many pieces and so few examples, you can fit anything. How to check: count the parameters in the EA's inputs tab and the trades in the test report.
  3. A different configuration for each year, broker or symbol. If every period asks for its own set file (a file with the parameters ready), the rule was fitted to each one instead of holding for all of them. How to check: run the same file on a period it wasn't made for.
  4. The period is short or hand-picked. Only the good year shows, or the test starts right after the worst month. How to check: ask for the years that were left out, the weak ones included, or run them yourself.
  5. The isolated peak. One parameter value wins big, and its neighbors lose. A real rule usually has a plateau: the nearby values work too, a little better or a little worse. How to check: change the parameter a little in each direction and run again. The figure right below the list shows the difference.
  6. The profit depends on a few trades. Take out the biggest wins and the rest doesn't pay for itself. How to check: the report's list of deals, sorted by result. Redo the sum without the biggest wins.
  7. The distance between the years of the choice and the years outside it, or the silence about it. Earning less outside the period in which the parameters were chosen is expected: the market changes, and the stretch of the choice always has the advantage of having been seen. The sign is the size of that distance, and you can only measure what is published. And there is a worse case: the years outside simply don't appear. How to check: put the years inside and the years outside side by side, each one starting from the same deposit, and judge the distance yourself. The tests in the next section do that in your MetaTrader.
Peak or plateau: how to tell whether a robot's parameter is luck or a rule
At the peak, one step to the side and the profit is gone.

How to test a robot for overfitting

The six steps run in the Strategy Tester or on a demo account, without programming:

  1. Split the history in two. One stretch to choose the parameters and another only to check, without changing anything. The second is the out-of-sample test: data that didn't help choose.
  2. Turn on the Strategy Tester forward. In the Forward field, choose 1/2, 1/3, 1/4 or a date (Custom). The optimization works on the beginning, and the result of the held-back piece shows in the Forward tab. The whole tester screen is in the guide to how to backtest on MT5 with real ticks and in the official Strategy Tester documentation.
  3. Do the walk forward, explained right below.
  4. Nudge the parameters. One step to each side, on each adjustment. If the result holds, it is a plateau. If it collapses, it was a peak.
  5. Change the conditions. Your broker, your real cost and the Every tick based on real ticks mode. How much the result changes from one mode to another is in the guide on 1-minute OHLC or real ticks.
  6. Run it on a demo account, live. Weeks of live prices and play money show what no history shows: run it on a demo account before real money.

What each test catches:

Test What it catches How to do it in MT5
Out of sample a rule that only holds in the stretch where it was chosen choose in one period and check in another, without changing anything
Tester forward the same, on a piece at the end of the period "Forward" field, result in the "Forward" tab
Walk forward a rule that only holds in one phase of the market several windows in a row: choose, check, slide
Parameter neighbors the lucky peak change each parameter a little and run again
Another broker and real cost a fit to one broker's prices test on your broker, with real ticks
Live demo account what no history shows run it on a demo for weeks

Walk forward: choose, check and slide the window

Walk forward repeats the forward several times across the history. You choose the parameters on one stretch, check on the next, slide the window and repeat. For example: choose on six months and check on the next three; slide three months, choose again and check again.

If the rule only passes in one window, it memorized that phase of the market. If it passes in most of them, in the sideways months and the trending ones, it has a better chance of being a rule.

Walk forward: choose, check and slide the window across the history
Each window checks what the previous one chose.

Walk forward lowers the risk of overfitting; it doesn't zero it. And not every gap between the test and the account is overfitting: the rule can be right and the execution can have changed, with slippage, a wide spread on news or a terminal that was off. That is another conversation, in the guide on why a real account's result differs, and how much is normal.

Overfitting in a robot for sale: what to ask the seller

On someone else's robot, you can't see how the parameters were chosen, but you can ask, and the page can answer:

  • In what period were the settings chosen? And what does the page show outside it?
  • Does the page show the weak years, year by year, or only the total for the period?
  • Does each year start from the same deposit, so one year doesn't hide another?
  • How many adjustments do you have to make? Is there a different set file per broker or per year?
  • Is there a live account to compare with the test?

A page that answers all five has saved you the work. For the rest of the checking, see the 5 numbers that separate a serious robot from a promise and the 5 rules to check every number before you turn on an EA.

Our EAs: the years left outside the choice

The first question on the list is the hardest, and the Doberman Gold page answers it in writing: its settings were chosen looking at 2025 and 2026, and 2023 and 2024 were left outside that choice.

By this post's rule, then, the years that serve as the test outside Doberman Gold's choice are 2024 and 2023, not the two most recent. That is why they are on the page, one by one. In the test with real ticks, on the Balanced profile (the default), with each year restarting from the same deposit:

Year Were the settings chosen looking at this year? Result
2026, through November 8 yes +126%
2025 yes +162%
2024 no +56%
2023 no -14%

Outside the choice, 2024 made +56%, with a largest drop of 14% on equity (12% on balance). 2023 closed at -14%, with a largest drop of 32% on equity (30% on balance). The largest drop, the drawdown, comes in both measures: equity also counts what is open, and balance only the closed trades.

The page also says why 2025 and 2026 made so much more: gold moved a lot more in those years, and inside each year the automatic lot follows the balance, so each gain increases the next trades, and each loss shrinks them. And it says in so many words that 2025 and 2026 were exceptional years, not a rate to project.

No test proves that a rule memorized nothing of the past. What can be done is to show what was left out and let you judge with the numbers in hand.

See all of it on the page: Doberman Gold: the period of the choice and the years outside it.

And three things hold on every page of our EAs:

  • Choosing the profile is the whole setup, and there is no set file to download. Sign 3 has nowhere to happen: there is no file per broker or per year, and the same profile runs across all the published years. You pick the pace and switch it on.
  • Each year restarts from the same deposit, so one year doesn't hide another.
  • The weak years are published, year by year, next to the strong ones.

The best overfitting test is the one you run yourself: see each EA's year-by-year, weak years included, and download the free demo.

Frequently asked questions

Are overfitting and curve fitting the same thing?

In trading, yes. Curve fitting is the name that stuck among traders for the same problem: tweaking the parameters until the curve of the past looks good.

What is the difference between overfitting and underfitting?

In overfitting, the rule memorizes the past: it wins on the history and loses on new data. In underfitting, the rule is too simple and catches nothing, not even in the past. What you are looking for sits in the middle: few adjustments, which keep holding outside the period in which they were chosen.

Is optimizing an EA always overfitting?

No. Optimizing a little, looking for the plateau and checking out of sample is using the tool the right way. Overfitting is optimizing until it fits: more adjustments, more values, more runs, until the curve is perfect.

How much history prevents overfitting?

No amount of history solves it alone. A long history helps, but what protects you are the trades outside the period of the choice and the years of different markets: sideways and trending, calm and wild. A whole history used in the choice proves less than a smaller stretch that was left out.

Does walk forward eliminate overfitting?

It reduces it; it doesn't eliminate it. It checks the rule on several windows that the choice didn't see. But anyone who tests many versions of the walk forward and keeps the best one is back to flipping coins. The live demo account is the next filter; the real account with a small lot is the last.

Does a robot with artificial intelligence have more risk of overfitting?

It tends to, because an AI model has far more internal adjustments to fit the past. The name "artificial intelligence" protects against nothing: the same questions apply, and the out-of-sample test matters even more.

A result only counts on data that didn't help choose it. On the pages of our EAs, you see the year-by-year, weak years included, and on the Doberman Gold page, the years that were left outside the choice. Download the demo, run those years in your MetaTrader and check: our gold EAs, side by side, with the free demo.

Read next