MT5 expert advisor for gold: Running Trendline v5.0 Strategy on XAUUSD

MT5 Expert Advisor for Gold: Running Trendline v5.0 Strategy on XAUUSD
An MT5 expert advisor for gold lets you run pre-built entry signals as real broker orders, each with a defined stop loss that scales to market volatility. Trendline v5.0 Strategy trades four switchable signal modes on XAUUSD with position sizing tied to your risk per trade, so a 1% stop-loss setup stays 1% even as gold's daily range shifts.
The setup: A real XAUUSD session
You open MT5 at the start of the London session, drag the Trendline v5.0 Strategy onto your 4-hour XAUUSD chart, and set it to Mode 1 (pullback on stacked EMAs) with 1% risk per trade. The Strategy immediately begins watching the closed bars. When the bar closes and a pullback entry fires, it calculates the ATR(14) over the last two weeks of data, multiplies it by 2.8 (the default stop distance), and places the stop that far away from your entry. If gold's volatility climbs, ATR climbs with it, and the next stop widens automatically. If volatility drops, stops shrink. No manual recalculation needed.
Now the position is live: the Strategy has split your total lot size across three broker orders, one for each target. TP1 sits one risk-multiple above entry (1R), TP2 at 2R, and TP3 at 3R. When TP1 closes, the remaining two stops move to breakeven, so your initial 1% risk is locked off the table. The next signal only fires once this trade group has fully closed, keeping just one clean setup on at a time.
The four signal modes on XAUUSD
Each mode reads the 50-bar Sentiment Range MA and responds differently to price:
- Mode 4 (mean-reversion, default): Watches for RSI(14) reversals at the extremes of the 50-bar range while the Sentiment MA is flat. On XAUUSD in quiet weeks, this fires pullback shorts into resistance and longs into support.
- Mode 1 (pullback): Trades touch-and-confirm: when the three-bar EMA stack aligns in trend order and price pulls back to the middle EMA, it enters in the stack direction.
- Mode 2 (trend formation): Enters when the three EMAs first stack in trend order, catching the start of a new trend leg.
- Mode 3 (RSI crossover): Runs a fast/slow RSI crossover for smoother entries in choppy price action.
You choose one mode at a time and adjust the Sensitivity slider (1-9) to speed up or slow down the signal timing. Lower sensitivity triggers faster; higher waits for more confluence.
Session timing on gold
Gold is most liquid during the London and New York overlaps. The Strategy includes a session filter: set InpSession to "0800-1700" server time to stay out of the Asian quiet zone and the Friday close. You can also enable an overnight window if your broker trades 24/5 gold and you prefer European evening setups.
Risk per trade in practice
You set InpLotMode to Risk % and InpRiskPercent to 1. The Strategy now works backward from your stop. If the ATR stop is 50 pips wide on a 100,000-unit contract, it calculates how many lots you can trade so that a loss at the stop costs exactly 1% of your current account equity. If gold rallies and your account grows, the next trade automatically sizes up proportionally. If a losing streak shrinks your equity, position sizes fall too. Over dozens of trades, this keeps your account drawdown predictable and under your control.
What to expect in ranging weeks
Ranging weeks on gold mean RSI oscillates around 50 and the Sentiment MA is flat. Mode 4 (mean-reversion) is built for this: it fades rallies into the 70-80 band and dips into the 20-30 band. But ranging also produces whipsaws. A pullback entry (Mode 1) can trigger on a false pop into the 50-band MA and stop out quickly. The Strategy does not predict whether a range will hold or break; it waits for the setup and lets the ATR stop define the loss. To know what to expect in your specific timeframe and session, you must test it on a demo account over at least four weeks of live market data, including both trending and quiet periods.
What it does not do
- It does not guarantee profit or predict market direction. Mode 4 mean-reversion works in ranges but can fail in strong trends. Modes 1-3 catch trends but can produce false starts in choppy price.
- It does not hide bad entries or bad risk management. An entry signal is only as good as the market context you choose to trade it in. A badly sized position or an oversized ATR stop can still wipe an account.
- It does not work on low-liquidity gold contracts or brokers with wide spreads. The Strategy works on any XAUUSD pair your broker offers, but execution slips if spreads exceed your slippage tolerance (default 20 points).
- It does not run in the Strategy Tester without a valid ZynAlgo access key. You must have a key to backtest or live trade; there is no trial run. Test on a demo first.
Trading risk and disclaimer
Trading involves risk. The Trendline v5.0 Strategy is an automated trading tool for executing the Trendline v5.0 signal logic, not financial advice. Past performance does not predict future results. Always test on a demo account with real data before using real money.
Next step
Download the Trendline v5.0 Strategy, install it on your demo MT5 terminal, and drop it onto a XAUUSD 4H chart with Mode 1 and 1% risk. Set the session to your preferred trading window and let it run for four weeks. Track the trades, the ATR stops and how many hit TP1 vs how many stop out. Once you have a month of demo data, you know whether this approach fits your risk tolerance and your schedule. If it does, the Strategy scales with you: the same logic, the same stops, the same risk-per-trade rule, live on any instrument your broker supports.
Trendline v5.0 Strategy MT5
Execute Trendline v5.0 indicator signals automatically on MT5 with ATR stops, scaled take-profits and position sizing.

