The result first: five versions side by side
Every version uses the same entry: EMA 20 crossing EMA 50 on a closed H1 candle, risk 1% of the balance per trade, one position at a time. Each row changes one thing from the version it builds on.
| Version | What changed | Trades | Win rate | Profit factor | Net result | Max drawdown |
|---|---|---|---|---|---|---|
| A | Cross only. Stop 1,500 points, target 3,000 | 278 | 31.7% | 0.92 | -16.2% | 23.5% |
| B | A + trade only with the EMA 200 trend | 183 | 32.2% | 0.93 | -9.5% | 19.2% |
| C | B + ADX 14 above 20 | 159 | 34.0% | 1.02 | +0.2% | 14.6% |
| D | B with stop 2 x ATR and target 4 x ATR | 169 | 40.2% | 1.38 | +33.0% | 10.1% |
| E | D, but no target: exit on the opposite cross | 200 | 30.5% | 1.70 | +83.8% | 17.9% |
Backtest on past data, not a forecast. Net result includes swap. Drawdown is measured on closed trades. Full conditions in the next section.

How we tested
| Setting | Value |
|---|---|
| Symbol and timeframe | XAUUSD (gold), H1 |
| Period | 1 Jan 2024 to 27 Nov 2026, 17,214 H1 candles |
| Tester model | 1-minute OHLC, MetaTrader 5 Strategy Tester |
| Price data | IC Markets demo server |
| Deposit and leverage | $10,000, 1:100 |
| Position size | Risk 1% of balance per trade (lot from the stop distance) |
| Costs | Spread from the data and swap included; no commission |
| EA | Built in the EA Builder, compiled as a free .ex5 on 29 Nov 2026 |
The numbers 20, 50, 200, ADX 20 and ATR 2/4 were chosen before testing and never tuned. Tuning them on the same data would make every version look better than it is.
Build version A in the EA Builder, block by block
Find the Moving Average block
Open the library on the left and type "moving". Drag Moving Average onto the canvas twice.

Set the two averages
Name the first EMA Fast: period 20, method Exponential, price Close. The second EMA Slow: period 50. Shift (bar index) 1 means the value of the last closed candle, so a signal never appears and vanishes inside a candle.

Wire them into a Crossover block
EMA Fast into Value A, EMA Slow into Value B, logic "Crosses Above" for the buy. Add a second Crossover with "Crosses Below" for the sell. A dotted blue wire carries a number.

Open the trade
Connect each crossover to an Open Position block: Buy Market for the up cross, Sell Market for the down cross. The comment is written on every order, useful when you read the trade history later.

Size the position
Trade Management: lot type Risk % per Trade, risk 1, max open trades 1. With a 1,500-point stop on gold the EA opened 0.06 lot at the start: $10,000 x 1% = $100, and 1,500 points is $15 a unit, $1,500 per lot, so 100 / 1,500 = 0.066, rounded down to the broker's step.

Set the stop and target
Stop Loss and Take Profit: Points, 1,500 and 3,000. On gold with two decimals that is a $15 stop and a $30 target.

Check the whole diagram and build
Global blocks (setup, sizing, stops) need no wires. The two signal chains run left to right. Name the EA and press Download EA: the .ex5 is compiled on the server and is free.


Version A: gold rose about 75%, and the EA still lost 16%
Gold went from about $2,060 to over $5,000 during the test. Version A traded both directions and ended at $8,379. Buys made +$345, sells lost -$1,695, swap cost another -$271.
The win rate explains it. With the target at twice the stop, a trade pays 2 units or loses 1. Break-even is where 2 x wins = losses, which is one win in three, 33.3%. Version A won 31.7% of 278 trades: just under the line, and costs pushed it further down.

Why a fixed 1,500-point stop stopped working
A stop in points is a fixed dollar distance. As the price of gold rose, the same distance became a smaller and smaller share of the price, and of the normal hourly swing.
| Entry price (first trade of the period) | 1,500-point stop as % of price |
|---|---|
| $2,076 (January 2024) | 0.72% |
| $3,316 (July 2025) | 0.45% |
| $5,039 (March 2026) | 0.30% |
By 2026 the stop was 2.4 times tighter relative to price than in 2024, and normal noise hit it. Rule of thumb: if the symbol's price changed a lot over your test period, do not use a stop in points. Use ATR or a percent of price, which grow with the market.
Version B: only trade in the direction of the EMA 200
Add a Price Data block (Close, shift 1), a third Moving Average (EMA 200) and two Crossover blocks set to compare instead of cross: A > B for buys, A < B for sells. Then a Logic Gate set to AND joins each trend check with its crossover before the Open Position block.


Result: 183 trades instead of 278, drawdown down from 23.5% to 19.2%, but profit factor still 0.93. The filter removed losing and winning trades in almost equal measure, because the stop, not the entry, was the problem.

Version C: skip quiet markets with ADX
On top of B, an ADX 14 block compared with a Static Value of 20 joins both AND gates: no new trade when ADX is 20 or lower, which usually means a market without direction. Profit factor 1.02, net +0.2%, drawdown 14.6%. Break-even, with fewer and calmer losses. The fixed stop still capped what the entries could earn.

Version D: let volatility set the stop
Back to B (no ADX), one setting changed: on the Stop Loss and Take Profit block, type ATR, stop 2 and target 4. The stop is now twice the average range of the last 14 candles, wherever the price is. Because the lot is sized from the stop, a wider stop automatically means a smaller lot: risk stays 1%. Lots ranged from 0.01 to 0.16 over the test.
Profit factor 1.38, net +33.0%, drawdown 10.1%, win rate 40.2%. Same entries as B, very different result: the exit was the weak part all along.

Version E: no target, exit on the opposite cross
From D, set the take profit type to None and add two Close Position blocks: Close All Buys on the down cross and Close All Sells on the up cross. A trade now stays open until the trend turns.
Profit factor 1.70, net +83.8%. But look at how it got there: win rate 30.5%, average win $365 against an average loss of $94, a longest run of 13 losing trades, and the average trade held 68 hours, so swap cost $799. Most of the profit came from buys (+$8,509) during gold's rally; sells added +$675.

Version E is the right design if you can sit through ten or more losses in a row while waiting for a trend. If you cannot, D is the calmer choice: lower return, half the losing streak.
Does it hold up? Gold 2020-2023 and EURUSD
A result from one symbol and one period proves little. We ran the same files, unchanged, on gold from January 2020 to December 2023 and on EURUSD H1 over the same 2024-2026 period.

| Version | Gold 2024-2026 | Gold 2020-2023 | EURUSD 2024-2026 |
|---|---|---|---|
| A | -16.2%, PF 0.92 | -17.7%, PF 0.88 | +8.6%, PF 1.85, only 28 trades |
| B | -9.5%, PF 0.93 | +21.2%, PF 1.29 | -11.1%, PF 0.55, 33 trades |
| D | +33.0%, PF 1.38 | +29.2%, PF 1.24 | -38.7%, PF 0.74 |
| E | +83.8%, PF 1.70 | +73.5%, PF 1.37 | -40.4%, PF 0.76 |
On gold, D and E made money in both periods. On EURUSD both lost about 40%. Gold had several long one-way moves in both periods; EURUSD spent most of 2024-2026 in ranges, and a crossover pays only in trends. Two more things the table shows:
- Points do not travel between symbols. 1,500 points is $15 on gold but 150 pips on EURUSD. Versions A and B on EURUSD were in effect a different, very slow strategy with too few trades to judge.
- Holding costs grow with holding time. Version E paid $2,282 of swap on gold in 2020-2023. On a symbol with a high swap, an exit-on-cross design can lose money even with good entries.
What these numbers do not tell you
- One broker's data and the 1-minute OHLC model. Real tick data and another broker's spread will move the numbers.
- No commission. On a raw-spread account, add the commission per lot to every trade.
- Gold rose strongly in both test periods. A design that rides long trends will look its best in such a market.
- Past results. A backtest is a record of how these rules behaved on past prices, not a forecast. Run any version on a demo account before real money.
Build version E yourself
| Block | Settings |
|---|---|
| Strategy Setup | Magic number: auto generate. Slippage 10 |
| Trade Management | Risk % per trade 1, max open trades 1 |
| Stop Loss and Take Profit | Stop: ATR 2 (period 14). Take profit: None |
| Moving Average x 3 | EMA 20, EMA 50, EMA 200; close price; shift 1 |
| Price Data | Close, shift 1 |
| Crossover x 4 | 20/50 Crosses Above; 20/50 Crosses Below; Close vs EMA 200 A > B; Close vs EMA 200 A < B |
| Logic Gate x 2 | AND: up cross + A > B; down cross + A < B |
| Open Position x 2 | Buy Market from the first gate; Sell Market from the second |
| Close Position x 2 | Close All Buys from the down cross; Close All Sells from the up cross |
Open the EA BuilderFree. Build it, then test it on your own symbol before trusting these numbers.
Questions people ask before they start
- Which moving averages work best for a crossover EA?
- We did not optimise the periods. 20/50 with a 200 filter is a common default. Changing the exit (version D and E) mattered far more in our test than any change to the entry.
- Why did the plain crossover lose money in a strong uptrend?
- Its fixed 1,500-point stop became too tight as gold's price rose, and it also traded every sell signal against the rally. Sells alone lost $1,695.
- Should a crossover EA use a take profit?
- On gold in our test, exiting on the opposite cross (version E) earned more than a fixed 4 x ATR target (version D), but with a lower win rate, a longer losing streak and higher swap. Choose by the drawdown you can accept.
- Can I use these settings on EURUSD?
- Not without testing. The same D and E files lost about 40% on EURUSD H1 in 2024-2026.
Updated:
