Best practices for parameter optimization of gold trading EAs

 

Hello everyone,

I wanted to share some lessons learned about parameter optimization, hoping to get your feedback and maybe some ideas to improve.

1. Walk-forward optimization beats simple single-period optimization. A strategy that looks great on one year of history often breaks on the next six months.

2. Use a realistic spread model and slippage. Backtesting gold with a 20-cent spread is very different from the real 35-50 cents you see during London/NY sessions.

3. Avoid overfitting by limiting the number of free parameters. I try to keep each EA to no more than 5-6 meaningful inputs, and I check that the equity curve stays smooth across different starting points of the test period.

4. Out-of-sample validation is essential. I reserve the last 20% of history and never look at it during optimization.

5. Be careful with tick data gaps around rollovers and low-liquidity weekends on XAUUSD.

What do you use in your own workflow? Do you prefer genetic optimization or full grid search? Any tips on avoiding curve-fitting when working with gold specifically?

Best regards

 
Phan Van Khoa:


Thanks for reading. One more thing I should mention: I always validate with different broker settings (spread, commission, and swap) because the same EA can behave completely differently across brokers. It would be great to hear how others handle broker-dependent parameters in their gold EAs.

 
One practical check is to validate each parameter set under different broker settings, especially spread, commission, and swap. For XAUUSD I also find it useful to limit the number of free inputs, keep an out-of-sample segment untouched, and compare walk-forward results against a simple baseline. If performance changes a lot when spread or session filters move, the strategy is probably overfit.
 
Use Python to optimize transactions if the strategy allows it, such as studying volume and yield variance (PMMV/PMVR) to determine the best liquidity times. We focus on making the expert trade during high liquidity times with mathematical proof, not the logic that says the highest liquidity occurs during the overlap between the London and New York sessions... If it were up to me, I would guide you through this path (analyzing data quantitatively and mathematically using Python, then applying the results and conclusions to your expert).
 

I use genetic optimization only to locate promising regions, then a smaller full grid around those regions. The best single pass is usually not interesting. I prefer a wide plateau where nearby settings stay profitable with similar drawdown.

After that I repeat OOS tests across several time windows and worsen spread, commission and delay. For gold I would also test another broker’s data, because one broker-specific result can look much more robust than it really is.

 
For gold, I’d optimize across several chronological windows and keep the final period untouched for validation. Choose a stable parameter area, not the single best result. Then repeat with higher spread, commission and execution delay. If the forward trade count collapses, the entry filters or parameter ranges are probably too tightly fitted.