MT5 demo testing an expert advisor: how to forward test on a demo account and log differences from your backtest

9 min read

How to run an MT5 expert advisor on a demo account, what to record while it trades, and how to compare each forward test trade with a Strategy Tester run over the same period.

MT5 demo testing an expert advisor: how to forward test on a demo account and log differences from your backtest

What MT5 demo testing an expert advisor actually means

MT5 demo testing an expert advisor means running the EA live on a demo account, on real-time prices, and recording every trade so you can compare it with what the Strategy Tester produced on history. The goal is not to confirm a backtest. It is to find where live conditions differ, such as spread, slippage, missed signals or execution timing, before any real money is involved. This is usually called forward testing, and the useful output is a written log of differences, not a profit figure.

If you have not run a historical test yet, start with the guide on how to test an expert advisor in MT5 with the Strategy Tester. This article picks up after that step.

Automate this on MetaTrader 5

A MetaTrader 5 expert advisor with documented inputs, full backtest settings and clear risk limits.

Instant deliverySecure payment97% satisfactionLifetime access

Set up a demo account that resembles the live one

A forward test is only as useful as the environment it runs in. Before attaching anything, match the demo to the account you would eventually trade.

  1. Open the demo with the same broker and, where possible, the same account type (raw spread, standard, netting or hedging). MetaTrader 5 explains the process in its help page on opening a demo account.
  2. Check the symbol name. Brokers often add suffixes, so EURUSD on one server can be EURUSD.r or EURUSDm on another. An EA hard-coded to one name may simply never trade.
  3. Open Market Watch, right-click the symbol and choose Specification. Write down contract size, tick size, minimum lot, lot step, stop level and swap. Compare them with the symbol you used in the Strategy Tester.
  4. Set the demo balance and leverage close to what you plan to use live, so position sizing behaves the same way.
  5. Note the server time zone. Session filters inside the EA usually read server time, and a different offset shifts every entry.

For index products, be precise about what you are trading. A US 500 CFD on an MT5 server is not the CME ES contract, which has a 0.25 tick size and its own trading hours. If your EA was designed around ES or CL futures behavior, confirm the MT5 symbol's tick size and session in its specification rather than assuming they match.

Attach the EA with the exact backtest configuration

Differences you find later are meaningless if the inputs changed between tests.

  • Save the inputs you used in the Strategy Tester as a set file, then load that same file on the demo chart. If you need a refresher, see how to load an MT5 set file and check it matches your EA version.
  • Use the same timeframe and symbol as the backtest.
  • In the EA properties, on the Common tab, enable algorithmic trading for that EA.
  • Turn on the Algo Trading button in the main toolbar. The MetaTrader 5 help on algorithmic trading describes the controls and how to confirm an EA is allowed to trade.
  • Check the icon in the top-right corner of the chart shows the EA as active, then look at the Experts tab in the Toolbox for its initialization message.

Record the EA version number, the set file name and the date you started. If you update the EA mid-test, start a new test log instead of mixing results.

A ready-made MT5 expert advisor with documented inputs and set files shortens this step, because the configuration you backtest and the one you attach to the demo come from the same documented file.

Keep the terminal running like a live setup

An EA only trades while the terminal is open and connected. A laptop that sleeps overnight produces gaps that have nothing to do with the strategy.

  • Run MT5 on a machine or VPS that stays on during the hours the EA trades.
  • Disable sleep and automatic restarts during the session.
  • Note every disconnection or restart in your log, with the time. The Journal tab records connection events, so you can cross-check later.
  • Be aware of weekends and holidays. Forex positions held over the weekend can gap at the open, and that behavior only shows up in a forward test, not always in a backtest built on modeled data.

What to record during the forward test

This is the core of the exercise. Build a simple spreadsheet with one row per trade and these columns:

ColumnWhat to writeWhere to find it
Signal timeTime the EA decided to tradeExperts tab, if the EA prints its decisions
Requested pricePrice the EA asked forEA logs or order comment, if available
Fill priceActual execution priceHistory tab
SlippageFill minus requested, in pointsCalculated
Spread at entrySpread when the order was sentEA logs, if printed, or Market Watch notes
Stop and targetLevels placedTrade or History tab
Exit reasonStop, target, trailing, time exit, manualHistory tab and EA logs
NotesDisconnection, news release, rejectionJournal and your own observations

On EURUSD, for example, a scalping EA that looked clean in the tester can show wider spreads around the daily rollover hour on a demo. That kind of detail is exactly what this sheet is meant to capture.

Reading the EA logs during the test

The Experts tab shows messages printed by the EA: initialization, signals, order requests and errors. The Journal tab shows terminal events such as connection status and trade server responses. Both are also saved as daily text files. Right-click inside either tab and choose Open to reach the log folder, or use File >> Open Data Folder and look in the Logs folders.

You do not need to diagnose every message here. Note the timestamp of anything unusual, such as a rejected order or an invalid stops message, and move on. For decoding specific errors, use the guide to MT5 expert advisor log errors explained.

Compare the forward test with a backtest over the same period

Once you have enough trades for the comparison to mean something, decided in advance as a number of trades or a number of weeks, run a second historical test that covers exactly the forward test dates.

  1. Open the Strategy Tester and select the same EA, symbol, timeframe and set file.
  2. Set the date range to the start and end of your demo run.
  3. Choose the most realistic modeling available, typically Every tick based on real ticks, if your broker provides that history.
  4. Run the test and export or note the trade list.
  5. Export your demo history: in the History tab, right-click and choose Report.

Now match trades row by row. You are looking for four types of difference:

  • Missing trades: the backtest traded but the demo did not. Common causes are a disconnection, a symbol name mismatch, a spread filter blocking entry or a stop level rejection.
  • Extra trades: the demo traded but the backtest did not. Often caused by a restart that reset the EA's internal state, or by tick data that differs between live feed and history.
  • Price differences: same trade, different entry or exit. Usually slippage, spread or a stop filled beyond its level during a fast move.
  • Timing differences: same trade, shifted by a bar or more. Check server time offsets and whether the EA acts on a new bar or on every tick.

Write the cause next to each mismatch when you can identify it, and "unknown" when you cannot. A growing column of unknowns is a reason to keep testing, not to go live.

Know the limits of a demo account

A demo forward test is closer to reality than a backtest, but it is still not live trading. Demo servers may fill orders without the queue, partial fills or rejections you can meet on a live account, and liquidity in a fast market can behave differently. Treat demo fills as a best case. If spread or slippage already damages the results on demo, expect live conditions to be at least as demanding. The CFTC's Learn and Protect resources are worth reading on the risks of leveraged trading and automated systems sold online.

It also helps to review your safeguards before any live step. Maximum spread filters, lot sizing and daily loss limits are covered in MT5 expert advisor risk settings explained.

Conclusion

Demo testing an MT5 expert advisor is a measurement exercise. Match the demo to your intended live account, attach the EA with the exact backtest configuration, keep the terminal running, record every trade with its fill, spread and exit reason, then compare it row by row with a Strategy Tester run over the same dates. The differences you document, and their causes, tell you far more than the account balance at the end. If you want a starting point with documented inputs and set files to run through this process, you can review the MT5 expert advisor available at SierraOnShop.

FAQ

How long should I forward test an EA on a demo account?

There is no universal duration. Decide before you start on a minimum number of trades or weeks that covers different market conditions, such as quiet sessions and major news days, and do not stop early just because results look good.

Can I run the same EA on demo and in the Strategy Tester at the same time?

Yes. The Strategy Tester runs in its own environment and does not interfere with the EA attached to a live demo chart, although heavy optimizations can slow a small computer or VPS.

Should I change inputs during the forward test?

Avoid it. Any change breaks the comparison with the backtest. If you must change something, close the current log, note the reason and start a new test period with the new set file.

Does a profitable demo test mean the EA will work live?

No. A demo test only shows how the EA behaved under demo conditions for that period. Live execution, liquidity and your own risk settings can produce different outcomes, and past behavior does not guarantee future results.

Run it in MetaTrader 5

Clement

Written by

Futures trader for more than seven years, specialized in order book and order flow scalping on US index futures, now building automated strategies. Founder of SierraOnShop.

More about the author

Ready to run an expert advisor?

A MetaTrader 5 expert advisor with documented inputs, full backtest settings and clear risk limits.

Instant deliverySecure payment97% satisfactionLifetime access