Chiến lược · August 22, 2026
EMA crossover with an RSI filter: the classic trend-following setup for XAUUSD
Why two EMAs plus one RSI filter remain the most common starting framework for bot trading — and how to describe it as a complete EA.
The EMA crossover is the first strategy most traders try when they start algo trading — not because it is magical, but because it is unambiguous enough that a machine cannot misread it. This article covers the structure, the parameters worth tuning, and the mistakes that make backtests look great while live results bleed.
The framework
- Base signal: fast EMA (20) crossing above the slow EMA (50) → short-term momentum beats the medium-term trend → consider Buy. Crossing below → consider Sell.
- RSI filter: only Buy when RSI(14) > 55, only Sell when RSI < 45. RSI here is not for picking tops and bottoms — it confirms strength and keeps you out of choppy crossings.
- Exits: fixed SL (typically 200–300 points on XAUUSD M15), TP at a 1:2 risk-reward ratio, with breakeven once profit reaches half the SL.
The edge is not the win rate (usually 35–45%) — it is small losses, big winners: one strong gold trend pays for many small stops.
Four parameters worth tuning (and two to leave alone)
| Parameter | Try | Note |
|---|---|---|
| EMA pair | 20/50, 21/55, 9/21 | Faster = more signals, more noise |
| Timeframe | M15, H1 | M5 and below is noisy on gold |
| RSI thresholds | 55/45, 60/40 | Tighter = fewer, better trades |
| SL | 200–350 points | ATR-based is even better |
Two things you should not over-optimize: TP (keep it as an R:R ratio) and the RSI period (14 is fine — 13 vs 15 is curve-fitting).
Why pretty backtests fail live
- Using the running candle: crossover signals must be evaluated on closed candles (index 1 and 2). Using candle 0 produces flickering signals — invisible in backtests, constant in live trading.
- No session filter: gold chops through the Asian session and loves fake crossings there. Restricting to London + New York improves trade quality significantly.
- Ignoring spread: XAUUSD spread runs 20–35 points. With a 100-point SL, spread eats a quarter of your stop — an SL that tight is self-sabotage.
- Both directions at once when position count is uncapped — cap it at 1 position while you are starting out.
How to describe this to the AI
Cover four things: entry (EMA pair + RSI thresholds, closed candles), exits (SL in points, TP as R:R, breakeven), sizing (% risk or fixed lot), filters (sessions, max positions). Don't make the AI guess — anything you leave out gets a safe default, documented in the bot profile.
Run this strategy as an MT5 bot
Describe the strategy in plain language; AI writes an MT5 bot in minutes. Download the .ex5 file on the web.
19,000 ₫ per build · new accounts include credit for the first bot
Trading Forex/CFDs carries high risk. Content is for education/reference only, not investment advice. EAs do not guarantee profits.