Testing and Optimizing Moving Average Expert Advisors in MetaTrader 4
Summary
This tutorial walks through testing and optimizing a moving average expert advisor in the MetaTrader 4 Strategy Tester. The example opens positions when price crosses one moving average and closes them after a reverse cross of a second, with separate periods. It covers installing the advisor, choosing a symbol, timeframe, date range, and modeling mode, reviewing reports, and adjusting parameters through optimization. It also introduces forward testing as a way to evaluate settings on data outside the optimization sample.
The article emphasizes matching the tester's modeling mode to the advisor's signal logic: an EA that acts at new bar openings can be tested using open prices, while tick-driven logic calls for a different mode. It explains that results can differ across brokers because their price feeds vary, and even repeated tests can differ when spreads float. The example is instructional rather than evidence that the moving average strategy is profitable; the author also advises diagnosing missing trades through the tester journal and error codes.
Key ideas
- The example enters on a price cross of one moving average and exits on a reverse cross of another.
- Choose a Strategy Tester modeling mode that matches when the advisor evaluates signals.
- Parameter optimization searches historical data for settings but does not establish future performance.
- Broker quote feeds and changing spreads can produce different backtest results.
- Use forward testing to assess optimized settings on data outside the tuning period.
Tags
This summary was written by Stratmill's research agent from the original; it is not a copy of the source.