Skip to main content

Moving Average Crossover EA Template for MetaTrader 5

The Moving Average crossover is the most popular trend-following strategy in forex trading. This free EA template uses a fast 10 EMA and slow 50 EMA crossover with ATR-based risk management, optimized for the London session. Build it in AlgoStudio without coding, customize the parameters, and export a production-ready MQL5 Expert Advisor in minutes.

What Is a Moving Average Crossover Strategy?

A Moving Average crossover strategy compares two moving averages with different periods. The fast MA (short period, like 10) reacts quickly to recent price changes. The slow MA (longer period, like 50) represents the broader trend. When the fast MA crosses above the slow MA, it signals a potential new uptrend. When it crosses below, it signals a potential downtrend.

This is a trend-following approach — it doesn't try to predict reversals or pick tops and bottoms. Instead, it waits for a trend to establish itself and then rides the move. The trade-off is a lower win rate (35–45%), but winning trades are significantly larger than losing trades because you hold positions through extended trending moves.

The strategy has been used by professional and retail traders for decades because of its simplicity and robustness. It works across all liquid markets and timeframes, making it an ideal starting point for anyone new to automated trading.

How This EA Template Works

BUY SIGNAL: Fast EMA (10) crosses above Slow EMA (50) during the London session
SELL SIGNAL: Fast EMA (10) crosses below Slow EMA (50) during the London session
EXIT: Stop loss at 1.5x ATR(14) or take profit at 2:1 risk-reward ratio

The London session filter (08:00–17:00 GMT) ensures you only trade during the most liquid hours, when major forex pairs have the tightest spreads and strongest trends. ATR-based stop losses adapt automatically to current market volatility — wider stops in volatile conditions, tighter stops in calm markets.

The strategy performs best in trending markets with clear directional moves. It underperforms in choppy, sideways conditions where the MAs keep crossing back and forth. Adding an ADX filter (only trade when ADX > 25) is a common improvement to avoid these whipsaw periods.

Default Parameters

These defaults work well on major pairs (EURUSD, GBPUSD) on H1. All parameters are exported as input variables so you can optimize them in the MT5 Strategy Tester.

ParameterValueType
Fast MA Period10EMA
Slow MA Period50EMA
Stop Loss1.5x ATR(14)ATR-based
Take Profit2:1 R:RRisk-reward
SessionLondon (08:00–17:00 GMT)Timing
Max Trades/Day3Risk
Position Sizing1% risk per tradeRisk

How to Build This EA Without Coding

1. Create a new project in AlgoStudio

Sign up for free (no credit card required) and click “New Project”. Name your project “MA Crossover Strategy” and open the visual builder canvas.

2. Add timing and indicator blocks

Drag a Trading Sessions block onto the canvas and select the London session (08:00–17:00 GMT). Add two Moving Average blocks — set one to EMA period 10 (fast) and the other to EMA period 50 (slow). Connect both to the timing block.

3. Add trade execution and risk management

Add Place Buy and Place Sell blocks. Connect Stop Loss (set to 1.5x ATR with period 14), Take Profit (set to 2:1 risk-reward ratio), position sizing (1% risk per trade), and Max Trades Per Day (3). Your entire strategy is now visible on the canvas.

4. Export, backtest, and optimize

Click Export to generate a .mq5 file. Load it into MetaTrader 5 and backtest on EURUSD H1 with at least 2 years of historical data. Use the MT5 Strategy Tester optimizer to find the best MA periods — try ranges of 5–20 for the fast MA and 30–100 for the slow MA. Demo trade for 1–3 months before going live.

Optimization Tips

Test different MA period combinations

The 10/50 EMA is a strong default, but 8/21, 10/30, and 20/50 are all worth testing. The key is maintaining enough separation between the fast and slow period — if they're too close, you get excessive crossovers and whipsaws.

Add an ADX trend filter

The biggest weakness of MA crossover strategies is choppy, sideways markets. Adding an ADX block with a threshold of 25 ensures you only take trades when a real trend exists. This typically reduces trade count by 30–40% but significantly improves the win rate.

Don't over-optimize

If your backtest shows 90%+ win rates, you've probably overfitted to historical data. A realistic MA crossover wins 35–45% of trades with a positive profit factor. Prefer parameter sets that produce consistent results across multiple years and currency pairs.

Frequently Asked Questions

What timeframe works best for the MA crossover strategy?
H1 (1-hour) and H4 (4-hour) timeframes produce the best results. Lower timeframes like M15 generate too many false crossover signals, while daily charts produce very few trades. Start with H1 and test H4 if you want fewer but higher-quality signals.
Which currency pairs work best for MA crossover EAs?
Major pairs that trend well: EURUSD, GBPUSD, and USDJPY. Avoid range-bound pairs like EURGBP and exotic pairs with wide spreads. The strategy profits from sustained directional moves, so trending pairs are essential.
Should I use SMA or EMA for the crossover?
EMA (Exponential Moving Average) is recommended because it responds faster to recent price changes, catching trend changes earlier. SMA (Simple Moving Average) gives smoother but slower signals. Test both in backtesting — EMA 10/50 is a strong default.
What win rate should I expect from this strategy?
A well-optimized MA crossover typically wins 35–45% of trades. The strategy is profitable because winning trades are significantly larger than losers, using a 2:1 risk-reward ratio. You don't need to win most trades — you need winners that are bigger than losers.
Can I add more indicators to improve the strategy?
Yes. Common additions include an ADX filter (only trade when ADX > 25, confirming a trend exists) and an RSI filter (don't buy when RSI > 70, avoiding overbought entries). Keep it simple — 2–3 indicators total is the sweet spot. More indicators usually means overfitting, not better results.

Build the MA Crossover EA in minutes

Create this strategy with AlgoStudio's visual builder. Free plan available — no credit card required.

Start Building Free