Q&AEA Optimisation

How to Optimise Your
XAUUSD Expert Advisor Settings

Published 15 June 2026 ยท 12 min read

Quick Answer

Optimise one parameter at a time, validate every change on out-of-sample data, and paper trade final settings for 4 weeks before going live. The most common mistake is changing multiple settings simultaneously and mistaking random improvement for genuine edge. Follow the 5-step process below.

The 5-Step Optimisation Process

Click each step to expand full details, criteria, and the common mistake to avoid.

What to Do

Run the EA with completely default settings across at least 6 months of historical data. Record every key metric before changing a single parameter.

What to Record

Win rate, profit factor, maximum drawdown, average trade duration, consecutive losing trades, Sharpe ratio.

Common Mistake

Starting optimisation without a baseline means you have no reference point. You cannot know if a change helped or hurt.

Go / No-Go Criteria

Go if you have at least 50 trades in the baseline. No-go if fewer โ€” not enough statistical sample.

What to Do

Review your baseline results and identify the single parameter most likely to address your biggest weakness. If max drawdown is too high, that is your focus. If win rate is low, check if the entry filter (spread, session time) is the lever.

What to Record

Which metric you are targeting, which parameter you hypothesise controls it, and your expected direction of change.

Common Mistake

Changing multiple parameters at once. If you adjust 3 parameters and results improve, you do not know which change helped. You may keep all 3 and unknowingly add two random variables.

Go / No-Go Criteria

Pick one parameter only. The one that most directly addresses your primary weakness.

What to Do

Change only your chosen parameter. Run the full backtest with that single change. Compare every metric to your baseline โ€” not just profit, but drawdown, win rate, and consecutive losses.

What to Record

Complete metrics table versus baseline. Note whether the improvement is consistent across the test period or clustered in specific months.

Common Mistake

Stopping if the equity curve looks better. Check whether the improvement is consistent across the full period or only appeared in one particular market phase.

Go / No-Go Criteria

Go if profit factor improved AND drawdown did not worsen significantly. No-go if only one metric improved at the expense of another.

What to Do

Take your improved parameter setting and test it on a date range you did not use during steps 1โ€“3. This is the most important step most traders skip.

What to Record

Out-of-sample profit factor versus in-sample profit factor. If the gap is large (in-sample 2.5, out-of-sample 1.1), the improvement was likely random.

Common Mistake

Treating the out-of-sample test as a place to make further adjustments. If you tune to the out-of-sample data, it is no longer out-of-sample โ€” it becomes in-sample and you lose the validation.

Go / No-Go Criteria

Go if out-of-sample profit factor is within 30% of in-sample. No-go if it drops more than 30% โ€” the change may be curve-fitted.

What to Do

Run the final settings on a demo account for 4 weeks minimum. This is your final reality check โ€” real market conditions with real spread, real slippage, real news events.

What to Record

Number of trades, win rate, drawdown, any trades that should have triggered but did not (slippage/spread rejection). Compare to backtest expectations.

Common Mistake

Skipping demo because the backtest "looks good." Backtests, even high-quality ones, cannot replicate 100% of live conditions. Four weeks of demo costs nothing except time.

Go / No-Go Criteria

Go live if demo results are within 20โ€“25% of backtest expectations. No-go if there is a large gap โ€” investigate why before committing real capital.

Optimisation Priority Ranking

Not all parameters are worth optimising equally. The table below rates each parameter across three dimensions and gives a recommended priority order.

PriorityParameterHigh Leverage?Over-fit Risk?Robust?Why
#1Lot Sizeโœ“LowYesHighest leverage โ€” directly controls risk and reward per trade. Not prone to over-fitting. Optimise first.
#2Spread Filterโœ“LowYesControls which market conditions allow entries. Setting too tight excludes too many trades; too loose lets in bad entries during news.
#3Session Windowโœ“HighNoCan be over-fitted to a specific profitable period. Test on out-of-sample data before locking in a specific window.
#4Stop Loss Pipsโœ“HighNoLarge impact on results but high over-fitting risk. A 5-pip change can dramatically alter backtests. Requires rigorous out-of-sample validation.
#5Take Profit Pipsโœ“HighNoSame risk as stop loss. Small changes significantly alter apparent performance. Validate thoroughly.
#6Max Simultaneous Tradesโ€“LowYesLower leverage impact but affects drawdown behaviour. For small accounts, keep at 1โ€“2 regardless of optimisation results.

The Curve-Fitting Trap: Why Over-Optimisation Is the #1 EA Killer

Curve-fitting happens when an EA's settings are tuned so precisely to historical data that they capture the noise of that specific period rather than a genuine recurring market pattern. The result looks perfect on backtest and fails in live trading โ€” sometimes immediately.

Here is how to recognise it in your own optimisation:

The settings only work on one specific year

If your EA backtest looks great on 2021โ€“2022 but underwhelms on 2023, the settings are tuned to the 2021โ€“2022 market structure, not to a durable pattern in XAUUSD.

Performance is hypersensitive to small parameter changes

If moving the stop loss from 25 pips to 27 pips changes the profit factor from 1.8 to 0.9, the strategy is fragile. Robust edges are not sensitive to 2-pip adjustments.

Out-of-sample results are dramatically worse

If your in-sample profit factor is 3.0 and your out-of-sample is 0.8, something is wrong. The gap should not exceed 30โ€“40% for a robust strategy.

The equity curve is unnaturally smooth

Real strategies have losing periods. If the equity curve looks like it was drawn with a ruler during the backtest period, that smoothness has almost certainly been optimised in.

Goldie Razor V2.8.4 ships with defaults that have been validated across multiple market regimes โ€” for most accounts, lot size and spread filter are the only parameters that need attention. The session window, stop logic, and trend filter are set to values that have proven robust across trending and range-bound XAUUSD conditions without requiring user-level optimisation.

What "Out-of-Sample" Data Means and Why You Cannot Skip It

Out-of-sample (OOS) data is historical data you deliberately set aside and do not use during optimisation. After you optimise on your main data range, you run the final settings on the OOS data only once. The result tells you whether the improvement you found was genuine or coincidental.

Example: 4-Year Data Split

In-Sample Period

Jan 2021 โ€“ Dec 2022

Run all parameter testing here

Out-of-Sample

Jan 2023 โ€“ Dec 2023

Validate final settings ONCE โ€” no changes after seeing results

Forward Test

2024 onwards

Demo account โ€” final confirmation before live

The critical rule: once you see the out-of-sample results, you are not allowed to go back and adjust settings. If you adjust and re-test, the OOS data is no longer truly out-of-sample โ€” it has now been optimised to. If your OOS results are poor, the correct response is to accept that your optimised settings may be curve-fitted and restart with different parameters, not to tweak until the OOS results look better.

Related Reading

Frequently Asked Questions

The clearest sign is a large performance gap between in-sample and out-of-sample results. If your EA shows a profit factor of 2.5 on the data you used for optimisation but drops to 1.1 on a different date range, the settings are curve-fitted to the first period rather than reflecting a genuine market edge. A second sign is extremely tight parameter sensitivity โ€” if changing the stop loss by just 2 pips causes a dramatic shift in results, the EA is over-fitted to very specific price behaviour that may not repeat.

Walk-forward testing divides your historical data into rolling windows: optimise on window A, validate on window B, then move forward and optimise on B+C, validate on D, and so on. This simulates how an EA would actually perform if you had continuously updated its settings over time. If the EA's walk-forward results are reasonably consistent across windows, that is strong evidence of a robust strategy rather than a curve-fitted one. Most traders never do this โ€” they optimise once on all available data and call it done.

Almost always lot size. It is the parameter with the highest leverage on your account risk and return, it is not prone to over-fitting (moving from 0.02 to 0.03 lots is a mathematical shift, not a market-fitting one), and it is the most important variable for matching the EA to your specific account size. Start there, get it right, then move to the spread filter if you are running on an account where spread varies significantly throughout the day.

A minimum of 2 years for initial optimisation, with at least 1 additional year held back as out-of-sample data. The reason for 2+ years is that XAUUSD goes through multiple market regime types within that period โ€” trending periods, range-bound periods, high-volatility events, and quieter stretches. Settings that only work in one regime (e.g. a strong uptrend) are not robust. For XAUUSD specifically, including the 2020 COVID volatility period and the 2022โ€“2023 mixed range period gives a reasonable range of market conditions.

When your out-of-sample results are consistent with your in-sample results, and when further parameter changes only produce diminishing improvements. A practical rule: if you cannot improve the profit factor by more than 0.1 on the in-sample data with any single parameter change, you have likely found the local optimum. The other signal to stop: when you have been changing settings for more than 2 weeks without a consistent out-of-sample validation pass. At that point you are almost certainly introducing curve-fitting.

Goldie Razor V2.8.4

M15 breakout + H4 EMA filter โ€” built for XAUUSD on MT5

View Goldie Razor โ†’