Best practices for parameter optimization of gold trading EAs - page 2

Hi Phan,

a lot of good tester advice here already, so just one thing from the user side. All of these checks still run on
history.

What changed most for me was running an EA on a small live account for a few months before putting real size on
it, and only scaling once that held up. I'd keep the settings frozen in that phase, otherwise the clock starts again.

That's also where things show up that no tester setting gives you, like the stops glenfsl and @Bruce Fx described, or a
gap at the open jumping straight past the stop. That one cost me a prop challenge.

Best regards
Chris

I agree with the points about walk-forward testing, realistic execution costs and keeping an untouched out-of-sample period.

For gold EAs, I also prefer testing a parameter plateau rather than selecting a single best result. If nearby parameter values produce similar results, the setup is usually more robust than an isolated peak.

My validation process would include:

• realistic variable spread, commission and slippage
• separate in-sample and out-of-sample periods
• walk-forward testing across several market phases
• testing different starting dates
• checking the equity curve and drawdown, not only profit factor
• comparing results across broker conditions
• stress-testing execution costs around volatile sessions and news releases

I would also keep the number of optimized inputs limited. A high-quality result should remain reasonably stable when the spread, slippage, date range or parameter values change slightly. If performance disappears after a small change, it may be curve-fitted rather than a robust trading edge.

Great list. I agree with all five points. A few things from my own workflow that added the most on top of them:
1. Compare against random entries, not against zero.
For every rule I run the same stop, target and holding time with random entries, and test whether the real entries beat them (a simple t-test). Gold trended so strongly in some periods that almost any long-biased system looks profitable. The question is whether your entry adds anything beyond that.
2. Placebo test for filters.
When I add a filter (DXY, volume, sessions, etc.), I run it again with the filter data shifted by a year. If the shifted, meaningless version "improves" results almost as much, the filter is just fitting noise. This killed most of my "great" filter ideas.
3. Run your optimizer on fake data first.
I generate random-walk price data with no edge at all and run the full optimization on it. The best result on pure noise shows you what luck looks like with your number of parameters. Your real result needs to beat that clearly. With ~9,000 combinations, the top configs on noise still looked profitable in-sample.
4. Check how the top configs do out-of-sample as a group, not just the #1.
In one test, only 20% of my top-20 in-sample configs were profitable out-of-sample, which was worse than the average across all configs. That's a clear overfitting signal. Look for plateaus: whole groups of neighboring settings that work in both periods, not one sharp peak.
5. For gold, measure results in R (risk units), not dollars or fixed lots.
Gold's price and volatility have roughly tripled since 2021. In fixed-lot dollars, recent years dominate every metric and the optimizer just fits 2025–2026. In R units the years become comparable, and you can see whether the edge is stable.
6. Stress costs, then verify in MT5.
I re-run with costs doubled. If the edge disappears, it was never robust. Then I check that my research backtest and the MT5 real-tick test produce the same trades (I aim for 90%+ trade matching).
On genetic vs grid: I prefer a full grid when the space is small enough (a few thousand combinations), because it lets me see the whole landscape and pick a stable region. Genetic optimization is good at finding the single highest peak, which is often exactly the overfit one. If you use genetic, re-check the neighborhood of the winner with a small grid.
On spread: agreed, use your own broker's real spread from tick data rather than a fixed value. It varies a lot between brokers and account types, and it widens sharply around rollover and news.
Two things I'd add from the gold side. First, the fitness criterion matters as much as the method: maximizing balance lets the genetic optimizer chase a handful of lucky outlier trades. A custom OnTester() score, e.g. net profit / max equity DD, returning 0 below a minimum trade count, pushes it toward stable regions instead of spikes. Second, the 'last 20% never looked at' only stays out-of-sample once. After you check it and go back to tweak, it's part of the design set. A second untouched block, or the same rules on a related market (XAGUSD, or gold on another broker's feed), gives you a check that isn't contaminated.
Frederic Jean Andre Jouillerot #:
Two things I'd add from the gold side. First, the fitness criterion matters as much as the method: maximizing balance lets the genetic optimizer chase a handful of lucky outlier trades. A custom OnTester() score, e.g. net profit / max equity DD, returning 0 below a minimum trade count, pushes it toward stable regions instead of spikes. Second, the 'last 20% never looked at' only stays out-of-sample once. After you check it and go back to tweak, it's part of the design set. A second untouched block, or the same rules on a related market (XAGUSD, or gold on another broker's feed), gives you a check that isn't contaminated.
Hi Frederic,

the point about the last 20% is easy to forget. You look once, change one small thing, and its not out of sample anymore.

For me thats the main reason for the small live account phase I mentioned above. It's the only block I really can't look at in advance, so it can't become part of the design.

Chris :)
One gold-specific thing I haven't seen in the thread yet: inputs in points and hours don't travel between brokers the way they look.

Some feeds quote XAUUSD with 2 digits and some with 3, so the same 300-point stop is ten times wider on one than on the other, and the optimizer will happily find a "plateau" that only exists on that quote format. Same with session filters optimized in server time: a GMT+2/+3 server and a GMT+0 server give different results for the same hour inputs, and in the weeks when US and EU daylight saving change on different dates the NY open moves by an hour.

I convert stops to price distance (or ATR multiples) and hours to GMT inside the EA before optimizing. Otherwise the cross-broker test suggested above mostly measures the conversion, not the strategy.

Interesting guys..
I have an EA that works fine on forward testing and doing good on years of backtesting data. But I hardly understand why is it needed to test an EA on fake data? 
If the data is bad, then it just a waste of time to test on it.
Erman Ardianto #:
Interesting guys..
I have an EA that works fine on forward testing and doing good on years of backtesting data. But I hardly understand why is it needed to test an EA on fake data? 
If the data is bad, then it just a waste of time to test on it.
Hi Erman,

the idea isn't that the fake data is good data. Its a test if the EA depends on the exact price path of that one history. You change the prices a little, add some noise or a wider spread, and run it again. If the result stays roughly the same, the EA trades a real pattern. If it falls apart after small changes, it was fitted to that history.

Your forward test already does part of that job, because live prices are new data too. I'd just give it enough trades before you trust it.

Hope this helps :)
Chris