Why an EA Trades Worse Live Than in Its Backtest: Spreads, Slippage and Execution

Almost every trader who moves an Expert Advisor (EA) from the Strategy Tester to a live or demo account sees the same thing: the live results are worse than the backtest suggested. Sometimes a little worse, sometimes so much worse that the strategy looks like a different system.

Part of that gap is overfitting, which walk-forward testing is designed to expose. But a large part has nothing to do with the strategy's logic. It comes from the difference between a simulated fill and a real one: spreads, commission, swap, slippage, execution delay and the quirks of a particular broker's feed.

This guide breaks the backtest vs live trading gap into its parts, shows what the MetaTrader 5 tester does and does not model, and gives you a way to stress-test costs before you trade and to measure the gap once you do.

One point up front: making a backtest more realistic usually makes it look worse, and that is the point. A cost-realistic backtest does not predict live results either. It removes one known source of optimism, so that what remains is a fairer starting point.

The gap is made of several separate costs

It helps to stop thinking of "the live gap" as one mysterious number. It is the sum of several costs, each with its own cause and its own fix.

Spread

Every market order buys at the ask and sells at the bid. If your backtest uses a fixed spread that is tighter than what your account actually sees, every trade is quietly flattered. Real spreads are not constant. They widen around the daily rollover, at session opens, in thin holiday markets and around scheduled news. A strategy that trades at those moments pays far more than the average spread suggests.

Commission

Raw-spread accounts usually charge a commission per lot, per side. A backtest that ignores commission on such an account overstates every single trade. This is easy to fix and surprisingly often missed, because commission has to be configured rather than appearing automatically.

Swap

Positions held past the rollover are charged or credited swap. For a strategy that holds for days or weeks, swap can be a meaningful share of the result, and swap rates change over time. A backtest that uses today's swap rates for a ten-year history is an approximation at best.

Slippage

Slippage is the difference between the price you asked for and the price you got. It is usually small on calm market orders and much larger on stop orders and stop-losses in fast markets, which is exactly when it hurts. A gap over a weekend or a news release can fill a stop-loss well beyond its level. Most backtests fill stops at the stop price, or close to it, which is optimistic. On a prop-firm account, that extra slippage counts against the daily loss limit, so testing an EA against prop-firm drawdown rules should use cost-realistic fills.

Execution delay

Between your EA's decision and the broker's fill there is latency: your terminal, the network and the broker's server. For a strategy that holds for days, a few hundred milliseconds rarely matter. For one that tries to catch a few pips on a fast move, they can matter a great deal.

Broker and data differences

Two brokers' price feeds are not identical. Server time zones differ, which changes where daily bars open and close. Symbol specifications differ: contract size, minimum stop distance, volume step and filling mode. A backtest run on one broker's history and traded on another broker's account is testing a slightly different market.

What the MT5 Strategy Tester models, and what it doesn't

The MT5 tester is more realistic than many traders assume, but only if you configure it.

Cost or effectHow the tester handles itWhat to check
Spread"Every tick based on real ticks" uses the broker's recorded tick history, including its spreads. Generated-tick modes use the spread stored with the bar data or a value you set.Use real ticks where available, and check the spread value in your test settings is not unrealistically tight.
CommissionApplied from the symbol's commission settings, or set on a custom symbol.Confirm commission actually appears in the tester's trade results.
SwapApplied using the symbol's current swap settings.Treat long-hold results as approximate, since historical swap rates differed.
SlippageNot modelled as a random cost by default. Stops are generally filled near their level.Add a slippage allowance yourself (see below).
Execution delayThe "Delays" setting can simulate fixed or random execution delays.Test with a realistic delay rather than zero latency.
Data qualityDepends entirely on the history you have.Check for gaps and abnormal spikes before trusting any result.

Two of these, slippage and delay, need deliberate effort. The others mostly need you to check that the settings are what you think they are.

How to stress-test costs before you trade

The aim is not to guess the exact live cost. It is to find out how much extra cost the strategy can absorb before its edge disappears. If a small increase in cost wipes it out, you have learned something important for free.

Step 1: Work out the cost-to-edge ratio

Look at the strategy's average trade, before costs, measured in pips or points. Then compare it with the realistic round-trip cost of one trade: spread, plus commission converted to pips, plus a slippage allowance.

Hypothetical arithmetic, for illustration only. Suppose an EA's average trade before costs is 6 pips, and the realistic round-trip cost is 1.5 pips. Costs take a quarter of the average trade. Now suppose live spreads at the times this EA trades are 0.8 pips wider than the test assumed, and stops slip by an average of 0.5 pips. Cost per trade rises to 2.8 pips, close to half of the average trade, and the net average trade falls from 4.5 pips to 3.2 pips. Nothing about the strategy's logic changed, yet nearly a third of its net margin disappeared.

Compare that with a strategy whose average trade is 60 pips. The same 1.3 pips of extra cost barely registers. That is why short-term, high-frequency EAs are far more exposed to the backtest vs live gap than slower systems. The cost per trade is similar, but the edge per trade is much smaller.

Step 2: Re-run the backtest with heavier costs

Run the same test several times with progressively worse assumptions, and keep everything else fixed:

  • Spread at the realistic level, then 1.5 times and 2 times that level.
  • Commission set correctly for the account type you plan to use.
  • A fixed slippage allowance added to every entry and exit, and a larger one on stop-loss exits.
  • A realistic execution delay in the tester's "Delays" setting.

MT5 has no dedicated slippage setting, so add the allowance another way: raise the spread setting by the allowance, add it as extra commission on a custom symbol, or deduct it from each trade in the exported trade list.

Then look at how the results degrade. A robust strategy degrades gradually. A fragile one falls off a cliff at the first step. Pay most attention to the average trade, the profit factor and the drawdown, rather than the total return. Then run a Monte Carlo test on the cost-adjusted trade list, because higher costs shift the whole range of plausible drawdowns, not just the average.

Step 3: Check when the strategy trades

Export the trade list and look at the entry times. If a large share of trades open within a few minutes of the daily rollover, at a session open or around high-impact news, the average spread in your test settings understates what those trades will really pay. Either test those trades with much wider spreads, or ask whether the strategy should avoid those windows entirely.

Step 4: Check the broker's symbol specification

Before going live, compare the live account's symbol specification with the one used in testing: contract size, digits, minimum stop distance, volume step, filling mode and trading hours. A stop-loss that is closer than the broker's minimum stop distance will be rejected. A volume that does not match the volume step will be rejected. These are not edge cases. They are common reasons an EA behaves differently live.

How to measure the gap once you are trading

Once an EA has run on a demo or live account, you have something more valuable than any assumption: real fills. The best way to understand the gap is to run the tester over exactly the same period, on the same broker's data, and compare the two trade lists side by side.

Look for four kinds of difference:

  1. Price differences on matched trades. Same signal, different fill. This is spread and slippage, and you can measure it per trade.
  2. Timing differences. Trades that open a bar later live than in the test usually point to execution delay, an EA that was offline, or logic that depends on the exact tick it sees.
  3. Missing trades. A signal fired in the test but not live. Common causes are rejected orders, terminal downtime or a check that behaves differently in real time.
  4. Extra trades. Live trades with no matching test trade. These often point to a logic bug, such as an EA that re-enters after a restart because it lost track of its own positions.

In Python, matching the two lists by time is straightforward with pandas. Export both trade lists with an entry time, direction and entry price, then pair each live trade with the nearest test trade.

import pandas as pd

def match_trades(live, test, tolerance="15min"):
    """Pair each live trade with the nearest backtest trade in the same direction."""
    live = live.sort_values("open_time")
    test = test.sort_values("open_time")
    merged = pd.merge_asof(
        live, test,
        on="open_time", by="direction",
        tolerance=pd.Timedelta(tolerance),
        direction="nearest", suffixes=("_live", "_test"),
    )
    # positive = live fill was worse than the test fill
    sign = merged["direction"].map({"buy": 1, "sell": -1})
    merged["entry_cost_pips"] = (
        (merged["open_price_live"] - merged["open_price_test"]) * sign / merged["pip_size_live"]
    )
    unmatched = merged["open_price_test"].isna().sum()
    return merged, unmatched

The entry_cost_pips column tells you how much worse, or better, each live entry was than the simulated one. Do the same for exits. Averages are useful, but look at the distribution too: a handful of very large slippages on stop-loss exits can matter more than a steady small cost.

Use the measured costs to update your backtest assumptions, then re-run the stress tests above. This loop, measure then re-test, is what gradually closes the gap between what you expect and what you get.

Common mistakes that widen the gap

  1. Testing on one broker and trading on another. Different feeds, different server times, different symbol specifications. If you must switch, re-run the tests on the new broker's data.
  2. Using a fixed, tight spread for convenience. It is the single most common source of optimism in EA backtests.
  3. Forgetting commission on raw-spread accounts. Check that it appears in the test results, not just in the account terms.
  4. Assuming stops fill at the stop price. Gaps and fast markets make that untrue exactly when it matters most.
  5. Judging a live period that is too short. A few weeks of live trades cannot tell you much about the strategy's edge, though they can tell you a lot about its costs.
  6. Re-optimizing to make the backtest match live results. Fitting parameters to recent live trades is overfitting with extra steps. Fix the cost assumptions, not the strategy's parameters.

A short pre-live cost checklist

  • Backtest run with "Every tick based on real ticks" where the strategy is sensitive to price movement within a bar
  • Commission configured and visible in the test's trade results
  • Results re-run at 1.5 times and 2 times the realistic spread, with the degradation written down
  • Slippage allowance added, with a larger allowance on stop-loss exits
  • A realistic execution delay tested, not zero latency
  • Entry times checked for clustering around rollover, session opens and news
  • Live account symbol specification compared with the one used in testing
  • A plan to compare live fills with a same-period backtest once trading starts

Frequently asked questions

Why does my EA lose money live when the backtest was profitable?

There is rarely a single cause. The most common are costs the backtest under-counted (spread, commission, slippage), overfitting to the test period, and differences between the broker's live conditions and the data used in testing. Comparing live fills with a same-period backtest separates the cost part from the strategy part.

How much slippage should I assume in a backtest?

There is no universal figure. It depends on the instrument, the time of day, the order type and the broker. A practical approach is to start with a conservative allowance, larger on stop-loss exits, then replace it with the slippage you actually measure once you have demo or live fills.

Is "Every tick based on real ticks" always the best mode?

It is the most realistic mode in MT5 when good tick history is available, because it uses recorded prices and spreads. For a strategy that only acts on completed bars and has no intrabar stops, a faster mode may give similar results, but it is worth confirming that with one real-tick run.

Can a demo account show me the live gap?

Partly. A demo account shows the broker's spreads and execution logic, but demo fills can differ from live fills, especially for larger sizes or during fast markets. It is a useful step between backtest and live trading, not a substitute for either.

Does closing the gap mean the strategy will be profitable live?

No. Realistic costs make a backtest a fairer test, but no backtest predicts future market conditions. A strategy can be tested carefully and still lose money.

Want a second pair of eyes?

Start with our free Sample Stress-Test Report. It walks one anonymized, illustrative strategy through a full stress test, start to finish, so you can see what rigorous validation looks like before you test your own.

Read the Sample Stress-Test Report

Want your own backtest checked? The Strategy Audit + 60-minute call is a paid service at a launch price of £100, credited in full against our build and portfolio offers. You send an MT4/MT5 Strategy Tester report or trade-list CSV; what we can check depends on the files you supply, and walk-forward and parameter sweeps are not included because they need the strategy itself. It is analysis of strategy testing, not investment advice, and does not promise any trading or evaluation outcome. See the Strategy Audit

Disclaimers

CollosoTrading provides educational content and analytical services for retail and professional algorithmic traders. We do not provide regulated investment advice, financial advice, or personal recommendations. Trading derivatives, leveraged products, and CFDs carries a high level of risk and may result in losses exceeding deposits. Past performance, including any verified or unverified historical results referenced on this site, is not indicative of future results. Consult an independent regulated financial adviser before making investment decisions.

All figures are backtests or simulations unless marked LIVE. Hypothetical or backtested performance results have inherent limitations and may not reflect actual trading. No representation is made that any account will or is likely to achieve profits or losses similar to those shown. Individual results vary. Any figures in this article are hypothetical arithmetic for teaching purposes, not results from any strategy or account. We do not guarantee the outcome of any prop firm challenge.