Free MetaTrader 5 Expert Advisor · XAUUSD H4
Gold Trend Sentinel
It follows gold's trend and lets winners run. A trade opens only when three things agree: the daily trend, the H4 Supertrend and a UT Bot cross. Every trade has a stop 3 x ATR away that trails the best price and only ever tightens. An on-chart panel shows the filters, the trailing stop and the real risk of the next trade for your balance.
- XAUUSD · H4trend following, about 17 trades a year
- 3 x ATR trailstop on every trade, no fixed target
- -4.7%worst backtest drawdown at 1% risk
- FreePro edition for sizing and protection
How it trades
Once per H4 bar the EA checks the last closed bar. A buy needs all three: the last completed daily close is above its 200-day EMA, Supertrend (10, 3) on H4 points up, and the close crosses above the UT Bot line (key value 1.5, ATR 10). A sell is the mirror. It enters at market with a stop 3 x ATR(14) away.
At each new H4 bar the stop moves to 3 x ATR behind the best price since entry, if that is tighter, so a winning trade locks in more as it runs. An opposite signal closes the trade and opens the other way. Before every order the EA checks margin, the broker's stop and freeze levels, and that the account would survive the stop without reaching the broker's stop-out level.
Free and Pro
Two separate editions on the MQL5 Market. Both trade the same strategy with the same defaults, so the Pro edition's results at its default settings are the same as the Free edition's; Pro adds sizing, protection and convenience.
| Gold Trend Sentinel (Free) | Gold Trend Sentinel Pro | |
|---|---|---|
| Lot size | 0.01 (or the broker's minimum) | Fixed lot, or a risk level: Safe 1%, Medium 2%, High 3%, Very high 5%, or custom; from balance or equity |
| Account protection | — | Daily loss limit, daily profit target, max-drawdown stop, max trades a day |
| Trade management | — | Break-even and partial close (off by default); the 3 x ATR trailing stop always stays |
| Filters | — | High-impact USD news pause, trading days and hours, Friday cut-off, spread guard |
| Alerts | — | Push and e-mail: trade opened and closed, protection stops |
| Panel | Trend filters, trade, results | Plus buttons (close, pause, export CSV) and monthly statistics |
| Strategy, stop and default settings | The same in both editions. Trades XAUUSD only on live and demo charts; the Strategy Tester accepts any symbol. | |
| Price | Free | Paid, on the MQL5 Market |
No set file needed. The default inputs are the optimised settings, the same ones used for every backtest on this page: attach the EA to an XAUUSD chart and keep them.
Risk and recommended balance
The stop is 3 x ATR on H4, so its size follows gold's volatility. In 2026 it was about 115 USD per 0.01 lot (between 105 and 131 in most trades). So the balance decides how much even the smallest trade risks. The panel's Risk row shows the real figure for your balance before every trade.
| Balance | Risk of 0.01 lot at the stop | Level |
|---|---|---|
| 12,000 USD or more (recommended) | about 1% or less | Safe |
| 6,000 USD | about 2% | Medium |
| 4,000 USD | about 3% | High |
| 2,300 USD | about 5% | Very high |
| Less than 2,300 USD | more than 5% | Extreme |
| About 250 USD | Technical minimum: below it the EA places no orders, because twice the loss at the stop (a price gap) would reach the broker's stop-out level. | |
Where the broker's minimum lot is 0.10, multiply these figures by ten.
Backtest
The tested rule in Python on RoboForex-Pro XAUUSD history, October 2021 to October 2026, with spread, commission, slippage and swap. At 1% risk from 10,000 USD: 85 trades, net profit 2,956 USD, profit factor 2.45, worst drawdown 4.7%. With a fixed 0.01 lot: 1,340 USD, profit factor 2.04. About 17 trades a year, held 5 days on average.




Please read before trading it. Holding gold made more money over these years, but fell 26% at its worst against 4.7% for the EA, which moved almost independently of gold (beta 0.07) and earned about 5% a year above what its small gold exposure explains. The rule was chosen on 2010-2023 research and judged once on 2024-2026, and has not been re-tuned since. Most of the profit came from buys in a rising gold market; sells lost slightly. A forward test on new data started in October 2026. Test it on a demo account first. Past results do not guarantee future results.
Questions
Why did it not trade this week?
All three conditions must agree, which happens about 17 times a year. The panel shows which filter is blocking and what is allowed now.
Did it beat simply holding gold?
Not in raw profit over October 2021 to October 2026: holding gold made more. The EA's point is the smoother ride: a 4.7% worst drawdown against 26%, and returns that barely depend on gold's direction.
Does it need a VPS?
The stop sits on the broker's server, but the terminal must be running for new trades and for the stop to trail. A VPS keeps it running when your computer is off; one option is FXVM (affiliate link: I earn a commission if you sign up, at no extra cost to you).
Does it work with 2-digit and 3-digit gold quotes?
Yes. Prices come from the symbol itself, so both work without settings.
Do I need a set file?
No. The default inputs are the optimised settings, the same ones used for every backtest on this page.
How do I report a problem?
In the EA's inputs, SUPPORT group, set "Debug log for bug reports" to true and let it run until the problem happens again (or repeat it in the Strategy Tester). Then send the lines that start with DBG from the Experts tab, your inputs saved as a .set file and a screenshot of the panel by private message on MQL5 or in the product's comments. The log never contains your account number or password. Set it back to false afterwards.
Custom EAs and trading API integrations
I build trading software to order, from a strategy idea to something that runs on its own.
- MetaTrader 4 and 5Expert Advisors, indicators, risk panels and utilities, with the same checks as this EA.
- Trading APIsStrategies, order routing, alerts and dashboards on Alpaca, OANDA, Interactive Brokers and other brokers' APIs.
- Backtests firstA Python backtest of the rules before anything trades, like the one behind this page.
Message me on LinkedIn with what you have in mind. It is the quickest way to reach me, and I reply there.