Free learning tools Test your finance and trading knowledge before you build, buy, or automate.
Reviewed September 11, 2026 | MT5 Expert Advisor | Free EX5 + SET file

XAUUSD Breakout Retest EA MT5 Free Download

A gold-focused MetaTrader 5 Expert Advisor that waits for H1 EMA trend bias, confirms an M15 breakout, requires a retest of the broken level, then enters only after M5 candle confirmation. It includes risk-percent lot sizing, spread control, daily and peak drawdown guards, and staged stop protection.

What This Gold EA Does

The XAUUSD Breakout Retest EA is designed for traders who do not want a grid or martingale gold robot. The logic is intentionally selective: first it checks trend direction on H1 using EMA20 and EMA50, then waits for an M15 close beyond the prior 20-bar range. After the breakout, the EA does not chase price immediately. It waits for price to retest the broken level inside an ATR-based band, then uses a closed M5 confirmation candle for entry.

H1 Trend BiasBuy bias requires EMA20 above EMA50 and a closed H1 candle above EMA20. Sell bias mirrors the condition.
M15 BreakoutBuy setup requires a close above the prior 20-bar high. Sell setup requires a close below the prior 20-bar low.
Retest FilterThe retest band defaults to 0.15 x ATR(14), helping the EA avoid entries that never return to the breakout level.
M5 ConfirmationEntry waits for a closed M5 confirmation candle above the previous candle high for buys, or below the previous low for sells.

Strategy Diagrams

XAUUSD breakout retest EA buy setup rules for MT5

Illustrative buy setup: H1 trend, M15 breakout, retest, M5 confirmation and 3R target structure.

XAUUSD breakout retest EA sell setup rules for MT5

Illustrative sell setup: breakdown, retest of broken support as resistance, then closed M5 bearish confirmation.

Risk Management and Trade Protection

The default preset uses 0.25% equity risk per trade, one symbol/magic position by default, and a maximum of two entries per day. Stops are placed beyond the retest extreme with optional ATR or point buffer. The target defaults to 3R, where R is measured from filled entry to the original stop. The EA never widens an existing stop.

Price ReachesStop ActionPurpose
+0.8RMove SL to -0.5RReduces worst-case loss after early progress.
+1.0RMove SL to entry plus optional offsetBreakeven stage for capital protection.
+1.5RMove SL to +0.5RLocks partial R while leaving room for trend continuation.
+2.0RMove SL to +1.0R, then optional M5 swing trailingProtects gains after a strong move.

Backtest Snapshot

The included Strategy Tester snapshot is for transparency, not a profit guarantee. The test used XAUUSDm on M5 from January 1, 2026 to September 10, 2026, with 99% history quality and a $1,000 initial deposit.

XAUUSD Breakout Retest EA MT5 backtest report snapshot
Total Net Profit$339.22
Profit Factor1.87
Total Trades83
Max Equity Drawdown8.11% ($118.13)

Backtests can differ from live results because of broker symbol suffixes, spread, execution speed, commission, slippage, server time and gold liquidity conditions. Test on demo first, use your broker's XAUUSD symbol, and reduce risk until behavior is verified.

Default Input Parameters

InputDefaultMeaning
InpTradeSymbolXAUUSDSymbol to trade. Change if your broker uses XAUUSDm, GOLD, XAUUSD.a or another suffix.
InpRiskPercent0.25Equity risk per trade when risk-percent lot mode is selected.
InpMaxEntriesPerDay2Limits overtrading during noisy gold sessions.
InpH1FastEMA / InpH1SlowEMA20 / 50Defines the higher-timeframe trend filter.
InpM15BreakoutBars20Lookback range used for breakout confirmation.
InpRetestATRBand0.15ATR-based tolerance around the broken level.
InpRewardRisk3.0Default take-profit distance as 3R.
InpDailyDDPercent3.0Stops new trading after the daily drawdown guard is triggered.
InpPeakDDPercent8.0Stops new trading after peak-equity drawdown protection is triggered.
InpMaxSpreadPoints80Blocks entries when spread is above the allowed broker-points threshold.
InpDeviationPoints30Maximum execution deviation in broker points.

Free Download

Download the compiled MT5 Expert Advisor and the matching preset file. The MQL5 source code is not included in the free download.

XAUUSD_Breakout_Retest_EA.ex5 Download EX5Install into MQL5/Experts/
XAUUSD_Breakout_Retest_EA.set Download SETLoad from the EA inputs window.

How to Install in MT5

  1. Download `XAUUSD_Breakout_Retest_EA.ex5` and copy it into `MQL5/Experts/`.
  2. Download `XAUUSD_Breakout_Retest_EA.set` and place it anywhere easy to find.
  3. Restart MetaTrader 5 or right-click Navigator and choose Refresh.
  4. Attach the EA to an XAUUSD or broker-suffixed gold chart.
  5. Load the `.set` preset from the Inputs tab, check the symbol name, then test in Strategy Tester or demo first.

This EA has a trial expiry built into the compiled file. It is intended for testing and education. It is not investment advice and does not guarantee profit.

FAQ

Is this a free XAUUSD MT5 EA?

Yes. The compiled `.ex5` file and matching `.set` preset are available as free downloads.

Is the editable source code included?

No. Only the compiled `.ex5` and `.set` file are public. The editable source file is not published.

Does the EA use grid or martingale?

No. The implementation notes specify no grid, no martingale and no add-on entries.

Which market is it designed for?

It is designed around XAUUSD gold breakout-retest behavior, but symbol input can be changed for broker suffixes or testing other markets.

🚀 Invite friends — Earn $5 You both get $5 credit on Go Ad · opencode.ai AI-Powered Coding Agent — Try Free Build apps, fix bugs & ship faster with opencode. Get $5 free credit when you join. × Ad · quo.com QuoPhone — $20 Visa Gift Card Free Sign up to Quo, subscribe 3 months, get a $20 Visa gift card. Atif's referral gift for you. ×