Home / Blog / XAU/USD

Precious metalsAutomation and EAs

XAU/USD Trading Strategies and Expert Advisors

Listen to this article

A 100-ounce lot on XAUUSD means a one-dollar move is worth 100 dollars per standard lot. A normal daily range can therefore be several hundred dollars per lot, and an Expert Advisor that ignores this will either be stopped out constantly or carry far more risk than its author intended.

This article looks at the families of automated strategy commonly tried on gold, what features of the instrument help or hurt each, and how to test them. It is technical analysis, not a recommendation. No strategy or robot works in all conditions, and no EA is the best for gold.

What an EA has to cope with on gold

Gold behaves differently from a major currency pair in ways that matter to code. Its range in dollar terms is large, so lot size must be small and calculated, not fixed. Spread widens at rollover and around major news. Price can gap over the weekend, and contract specifications (one lot, tick size, digits) differ by broker, so a hard-coded pip value is a common source of bugs.

The drivers are macro: US real yields and Federal Reserve expectations, dollar strength, central-bank buying, ETF flows and safe-haven demand. These can hold the market in a sustained direction for weeks, then leave it in a range for months. The full list is covered in the article on market drivers. For automation the point is simple: the instrument alternates between regimes, and any rule set is effectively a bet on one of them.

Trend following and breakout

Trend and breakout systems have worked in sustained macro regimes, typically when real yields or dollar moves push gold in one direction for a long stretch. Gold also tends to travel in large bursts, which suits rules that stay in a position and use a trailing stop. Moving-average crossovers, channel breakouts and higher-timeframe momentum filters are the usual building blocks.

The weaknesses are equally clear. In a range, breakouts fail repeatedly, and each failure costs the spread plus a stop. Gold often spikes through a level on news, then returns, so a breakout entry placed on a tick can fill at the worst price. Many such systems have a low win rate and rely on a few large winners, which demands patience through long losing runs. Breakout entries on a closed bar, with a volatility filter, reduce false triggers but also give back part of the move.

Mean reversion, scalping and session-based ideas

Mean reversion (fading stretched moves from a band, an oscillator extreme or a distance from a moving average) can look excellent in a range and fail badly when a trend begins. Gold's large moves mean the average winner is small relative to the occasional runaway loser, so a hard stop and a regime filter matter more than the entry signal.

Automated scalping targets small moves on one-minute to five-minute charts. On gold the spread is a large share of the target, and it widens exactly when volatility rises. Results also depend heavily on execution speed and slippage, so a scalper that tests well can disappoint on another broker. Session-based logic, such as trading the London open or the COMEX futures open at 13:20 UTC (12:20 in summer), exploits the fact that activity clusters there, but liquidity at those moments is also thin and fast. Details are in the article on trading times.

Volatility-based, indicator-based and grid approaches

Volatility-based stops using ATR are almost essential on gold, because a fixed 20-dollar stop is tight in one month and wide in the next. Scaling both stop distance and position size by ATR keeps the risk per trade comparable across regimes. The ATR and volatility calculator shows current ranges and the stop distances they imply.

Indicator-based systems (RSI, MACD, Bollinger Bands and combinations) are mostly trend or mean-reversion logic in different clothes, and their parameters are easy to over-fit. Stacking five filters usually means fewer trades and a better-looking backtest, not a better strategy.

Grid and martingale designs deserve plain language. They win small amounts often, which produces smooth equity curves, until gold moves a long way in one direction. A sharp one-way move, or a weekend gap, can open a loss that exceeds the account. A stop-loss on the whole basket, a cap on the number of levels and a fixed maximum lot are the minimum safeguards, and even those do not remove the tail risk.

Timeframes, spread and execution

Lower timeframes (M1 to M15) are dominated by costs and noise. Higher ones (H1 to D1) trade less often, tolerate the spread better and are less sensitive to execution quality, but need wider stops and therefore smaller lots. Neither is better in general: the right choice depends on capital, risk tolerance and how much slippage your broker produces.

Spread is not a constant. It is tight in the busiest hours, wider at rollover and around scheduled releases. Build a spread filter into the EA, and test with variable or deliberately pessimistic spreads. Check live figures with a live spread monitor and see the article on volatility and costs for context. Slippage is asymmetric on stops during fast moves, so assume that real fills are worse than the test.

Risk management and position sizing in code

Size from risk, not from habit. The calculation is: risk amount divided by (stop distance in price multiplied by contract size, 100 ounces by default), then rounded down to the lot step, usually 0.01. Read the contract size, tick value and minimum lot from the symbol properties at runtime, because brokers differ. If the rounded lot is below the minimum, the EA should skip the trade, not force the minimum.

Add limits that do not depend on the signal: a maximum number of open positions, a daily loss cap, a spread and margin check before every order, and a pause around scheduled news if the strategy is not designed for it. Use the risk of ruin calculator to see how risk per trade changes the probability of a deep drawdown, and remember that the inputs (win rate, reward-to-risk) are estimates, not facts.

Backtesting without fooling yourself

Data quality comes first. Use real tick data where possible, since modelling modes based on bars or generated ticks can hide the intrabar behaviour that decides whether a tight stop is hit. Include realistic spread, commission and swap, and check that the data covers gaps and rollover sensibly.

Then separate the sample. Optimise on one period, test on a period the optimiser never saw, and use walk-forward testing, which repeats this over rolling windows. Over-fitting shows up as a sharp peak in the parameter map: if a setting of 14 works and 13 and 15 do not, the result is noise. Prefer broad plateaus, few parameters and a rationale you could state before testing.

Test across regimes: a strong trend, a long range, a sharp spike, a low-volatility stretch. Stress the result with a Monte Carlo simulation of trade order, and review trade-level statistics with the MT5 report analyser. A backtest describes the past; it is not a promise, and it is normal for live results to be weaker.

Which approaches are fragile

Fragility usually has the same causes: tiny profit targets that costs can erase, parameters tuned to one year, no stop-loss, averaging down, and reliance on a single regime. A strategy that needs a tight spread, a fast fill and a calm market has three ways to fail.

Robust-looking behaviour is mostly boring: a modest number of parameters, volatility-scaled risk, a hard stop on every position and a defined condition under which the EA stands aside. Even then, a regime change can end an edge, so monitor live results against the test range and decide in advance what drawdown means the system is switched off. For more on discretionary context, see how to trade XAU/USD.

Treat any gold EA as a hypothesis with a cost and a risk budget: write down the regime it expects, test it where that regime is absent, and size it so that being wrong is survivable. Our Expert Advisors area and MQL5 coding service exist for those who want ready-made or custom tools, but neither changes the risks described here.

Frequently asked questions

Is there a best Expert Advisor for gold?

No. Results depend on the broker, execution quality, timeframe, capital, risk profile and the market regime, and these change. A system that suits a trending period may lose in a range. Judge any EA by its logic, costs, drawdown and behaviour across different conditions, not by one equity curve.

What lot size should an EA use on XAUUSD?

There is no universal figure. Calculate it from the amount you accept to lose, the stop distance and the contract size (usually 100 ounces), then round down to the broker's lot step. Because gold's range is large in dollar terms, the result is often a small lot such as 0.01 to 0.10 on modest accounts.

Why does my gold EA perform worse live than in the backtest?

Common causes are optimistic spreads, unmodelled slippage, low-quality tick data, over-fitted parameters and a regime that differs from the test period. Compare live trades with the test on spread, fill price and timing to find which factor accounts for the gap.

Are grid and martingale EAs suitable for gold?

They are among the riskiest designs on gold. They collect small gains until a sharp one-way move or a weekend gap produces a loss far larger than all previous gains. If tested at all, use a basket stop, a cap on levels and a maximum lot, and accept that tail risk remains.

This article is educational. It does not recommend any trade or product, and nothing here is a promise of results. Information only, not advice. Trading leveraged products carries a high level of risk and you can lose more than you deposit. Past behaviour does not predict future results. Read the risk disclosure.

More on this instrument

24 November 2026 · 8 min read

XAU/USD (Gold): History, Market Structure and Trading

A plain guide to what XAU/USD represents, how its price forms, where it trades and what its contract specification means on a retail platform.

Read article →
24 November 2026 · 7 min read

What moves XAU/USD: the main drivers of gold's price

Real yields, the dollar, central-bank buying and fear all move gold, but not equally or at the same time. Here is how to rank and track them.

Read article →
24 November 2026 · 8 min read

The best time to trade XAU/USD: sessions and liquidity

Gold moves most from the London open to the New York afternoon, but the best window depends on your style, your costs and the news calendar.

Read article →
24 November 2026 · 9 min read

XAU/USD Volatility, Spread and Liquidity Explained

What gold really costs to trade: how to measure its range with ATR, read the spread against a typical move, and test your own account's conditions.

Read article →
24 November 2026 · 8 min read

XAU/USD correlations: what gold is linked to

Gold is tied to the dollar, real yields and silver, but every link changes with the period measured. Here is what each relationship means and where it fails.

Read article →
24 November 2026 · 8 min read

How to Trade XAU/USD: Strategies, Risk and Behaviour

A practical look at how XAU/USD is traded, from the instrument's behaviour and styles to stops, position sizing, news and record keeping.

Read article →
25 November 2026 · 6 min read

The Best Time to Trade Gold (XAU/USD): Sessions, Overlaps and the Wall Street Open

Gold trades almost around the clock, but liquidity and movement cluster in a few hours. Here is how the sessions, overlaps and the US cash open fit together.

Read article →
24 November 2026 · 7 min read

Central Bank Gold Buying and What It Means for Gold

Central banks have bought record amounts of gold since 2022. Here is why they do it, and what the buying can and cannot tell a trader.

Read article →
25 November 2026 · 5 min read

Why Earth Cannot Make Gold: The Cosmic Origin of the Metal Behind XAU/USD

Gold was forged in violent cosmic events before the solar system existed. Here is how that origin explains scarcity, and why it matters less to XAU/USD prices than many assume.

Read article →
25 November 2026 · 5 min read

Fort Knox Gold: The Empty Vault Myth and What It Means for XAU/USD

The rumour that Fort Knox is empty has circulated for decades. Here is what is publicly known about the US gold vault, and why the debate still matters to XAU/USD traders.

Read article →
25 November 2026 · 5 min read

Ghost Gold: The Hidden Risks of Paper Gold in the XAU/USD Market

Most gold trading happens through paper contracts rather than physical bars. Here is how that structure works, where its stress points sit and how XAU/USD traders can respond.

Read article →
25 November 2026 · 5 min read

Flash Crashes in Gold: How to Recognise and Survive XAU/USD Danger Zones

A flash crash can move gold sharply within minutes, then reverse just as fast. Here is what makes these moves more likely in XAU/USD and how to limit the damage.

Read article →
25 November 2026 · 6 min read

Gold Liquidity Trap: Why Gold Can Fall on Good News

How forced selling in other markets can push gold lower even when the news looks supportive, and what to check before reading too much into a sudden move.

Read article →
24 November 2026 · 7 min read

Gold as a Safe Haven: What the Role Means for XAU/USD

Gold is called a safe haven, but the label hides real conditions: the dollar, real yields and volatility all shape how XAU/USD behaves.

Read article →
25 November 2026 · 5 min read

Gold vs Crypto: How Physical Gold and Digital Tokens Differ

A balanced comparison of physical gold and crypto assets on form, track record, industrial demand, behaviour in crises and infrastructure, and the limits of each comparison.

Read article →
25 November 2026 · 6 min read

History of the Gold Standard: When Paper Meant Gold

How paper money was once backed by gold, why the system gave way under war and Bretton Woods, and how the 1971 Nixon Shock shaped today's floating gold price.

Read article →
25 November 2026 · 5 min read

LBMA and COMEX Explained: How Gold Is Priced and Traded

How the London physical gold market and the New York futures exchange work, how they connect to the spot price, and why large orders can move gold in thin conditions.

Read article →
25 November 2026 · 5 min read

The First Coin: How Lydia Changed Gold Trading Forever

How standardised coinage began in Lydia, why electrum gave way to refined gold, and how the principle of trusted weight and purity still underlies the gold market.

Read article →
25 November 2026 · 6 min read

Gold in the Oceans: Why Seawater Gold Stays Out of Reach

Gold is dissolved in the oceans in enormous total quantity, but its tiny concentration makes extraction uneconomic. A look at the science and the barriers.

Read article →
25 November 2026 · 6 min read

Peak Gold: How Much Minable Gold Is Left, and Why It Matters

Known gold reserves are finite and new discoveries are harder to make. A general look at mine supply, ore grades and why the stock above ground matters.

Read article →
25 November 2026 · 6 min read

Trading the London Open in Gold: The Asian Handover Explained

The Asian range, the London open and the liquidity sweep: how gold often behaves at the handover between sessions, and why the first minutes can mislead.

Read article →
25 November 2026 · 6 min read

Gold in Central Bank Vaults Abroad: Who Really Controls It?

Gold held in custody abroad can be frozen by legal disputes over who may give instructions. A general look at custody, control and why it matters.

Read article →
25 November 2026 · 6 min read

Why the Human Brain Is Drawn to Gold: Lustre, Permanence and Trust

Gold has held human attention for thousands of years. A general look at lustre, permanence and the psychology of safety, and how that shows up in markets.

Read article →

Related instruments

Running into a technical issue or something that doesn't work right on this page? Please let us know straight away via our Contact page. That is how we find out what is broken and get it fixed.