How to stress-test a gold EA for crash scenarios
Huyen X. Vu · Quantex Research, AlgoTrade Pte. Ltd., Singapore · ORCID 0000-0002-2209-842X
Abstract
A normal backtest shows how an EA did on average; a stress test asks what happens on the worst days, with worse costs and slower fills. We propose six stress tests for gold EAs, among them replaying the worst days first, assuming gaps fill against the position, widening spreads and costs, and adding execution delay, with MetaTrader settings for each. Our Case study 01 shows why gold needs this: one average result hid a flat 2025, a negative 2023 and a strongly positive 2026, and our simulation reproduced only 69–77% of the largest real adverse events.
Keywords: stress testing; expert advisors; gold; XAUUSD; gaps; execution delay
JEL: G11; G17; G32
1. Introduction
A normal backtest tells you how an Expert Advisor (EA) did on average. A stress test asks a harder question: what happens on the worst days, with worse costs and slower fills? Gold is a good place to ask it, because its behaviour changes a lot between calm and volatile years. This note sets out a method, a checklist, and what our own Case study 01 showed.
The question
How do you test whether a gold (XAUUSD) EA survives a crash, a gap or a cost spike, and not only an average market?
Why gold needs its own stress test
In Case study 01 we re-tested one of our own systematic gold models on 4.4 years of one-minute data. Almost all of the positive result came from 2026, a year of unusually large gold moves. 2023 was negative in every variant we tried, and on 21 months 2025 was flat for every variant. One average number hid three very different markets. A stress test makes those differences visible before they show up in a live account.
2. Results
Six stress tests
1. Replay the worst days first
List the largest adverse moves in your history and run the EA through each one. Look at the worst equity drawdown, not only the closed result: an EA that holds losing positions can close in profit and still come close to a margin call on the way. If you use a simulation, check how many of the real worst events it reproduces. In Case study 01 our simulation matched about 69–77% of the largest real adverse events, so we treat it as a model, not a record.
2. Assume gaps fill against you
When the market reopens after a weekend or a pause, the first price can be far from the last one. A stop loss is then filled at the next available price, not at the level you set. Re-run the test with stops filled at the reopening price after every gap, and check whether the account survives the worst one. We are starting a separate study on gold weekend gaps.
3. Widen the spread and costs
Spreads on gold widen around news, rollover and thin hours. Test with a worst-case spread, plus commission, swap and slippage, not only the typical spread. In MetaTrader 5 one way is a custom symbol with changed properties; an MQL5 article by Denis Kirichenko shows how to widen the spread on custom-symbol data for a stress test.
4. Add execution delay
The MetaTrader 5 tester can run with "No Delay", where orders fill at the requested price, or with "Random Delay", where a delay of 0 to 9 seconds is chosen at random, or with a fixed delay (MetaTrader 5 Help). Run both and compare. A model whose edge disappears with a few seconds of delay will struggle on a fast gold market.
5. Change each rule slightly
Move each setting a small step up and down. If the result breaks, the effect is weaker than it looks. In Case study 01, one small change (the minimum distance between entries, set to $0.10) turned the best variant negative and roughly doubled its worst drawdown.
6. Split the test by year and regime
Report each year on its own and mark calm and volatile periods. Treat calm years as the base case and very volatile years as the exception, not the plan. Use the tester's forward period, which always takes the later part of the range, to check settings on data they were not tuned on (MetaTrader 5 Help).
3. Discussion
How to read the results
Set risk from the worst stress result you found, not from the best backtest, and add a margin of safety. That is what we did after Case study 01: we withdrew an earlier risk setting that, on that history, would have led to a drawdown of about 99%, and we now size from a weaker variant. For the wider gaps between backtest and live results, see Why an EA backtest is profitable but the live account loses.
Checklist: stress test before you go live
- Worst days: replay the largest adverse moves; record the worst equity drawdown.
- Gaps: fill stops at the reopening price after every gap.
- Costs: worst-case spread, commission, swap and slippage included.
- Delay: compare No Delay with Random Delay.
- Sensitivity: change each rule slightly; note which change breaks the result.
- Regimes: results by year; calm years as the base case.
- Risk: size from the worst case found, plus a margin of safety.
- Record: confirm on new data and in live conditions, with a record others can check.
4. Limitations
Limits of this note
This is a general method; the numbers come from one model in Case study 01. A simulation is a model, not a record, and real execution can differ.
Appendix
FAQ
What is an EA stress test?
A backtest run under worse conditions than normal: the worst historical days, gaps, wider spreads, slower fills and slightly changed rules. It shows how the EA behaves when things go wrong, not on average.
Is a long backtest enough for a gold EA?
A long test helps, but only if you look inside it. In Case study 01, 4.4 years contained a negative year (2023) that the average result hid. Split by year and stress the worst periods.
Can the MetaTrader 5 tester do a stress test on its own?
Partly. It can add execution delay, use real ticks and run a forward period. Wider spreads or changed data need a custom symbol, and gap fills and worst-day replays usually need your own scripts.
Related notes
Declarations
- Author: Huyen X. Vu, Quantex Research, AlgoTrade Pte. Ltd., Singapore (ORCID 0000-0002-2209-842X).
- Data availability: Public sources are listed under Sources. Results for our own models come from internal records that are not public; summary figures are shown in the note.
- Use of AI tools: Data processing, analysis code and drafting were assisted by AI tools (Claude, Anthropic). The author checked the results and is responsible for the content.
- Conflict of interest: The author is the founder of AlgoTrade Pte. Ltd., which develops and runs systematic trading models.
- Funding: No external funding.
- Peer review: Not yet peer reviewed. Comments are welcome at info@quantex.com.sg.
- How to cite: Vu, H. X. (2026). How to stress-test a gold EA for crash scenarios. Quantex Research, AlgoTrade Pte. Ltd. https://quantex.com.sg/research/2026-10-17-ea-stress-test-gold/