Why Your Expert Advisor Works in Backtest but Fails on a Live Account
A profitable Strategy Tester report is not proof of an edge. These are the seven gaps between backtest and live trading that cause most failures, with a practical test for each.
Most backtest-to-live gaps come from seven causes: unrealistic spread, slippage and commission; low-quality tick data; look-ahead or repainting logic; overfitting to one period; execution differences such as latency and stop-level rejections; strategies that only worked in one market regime; and hidden risk in grid or martingale money management. You can test for every one of them before risking real money.
1. Trading costs are modelled too kindly
The tester often assumes a fixed or average spread, no slippage and no commission. Live, spreads widen at rollover and around news, ECN accounts charge commission per lot, and market orders fill at a slightly worse price. The shorter your average trade, the more these costs eat the edge: a scalper making 3 pips per trade can be wiped out by a 1.5 pip cost increase.
- Test with variable spread from real ticks, not a fixed value.
- Add your broker’s real commission and swap rates to the calculation.
- Stress test: widen the spread by 50% and then 100%. If the profit disappears, the strategy has too little margin for error.
2. The price history is not realistic enough
On MetaTrader 4 the tester builds ticks from M1 bars, and “modelling quality” rarely reflects what the market really did inside a candle. On MetaTrader 5 you can choose Every tick based on real ticks, which replays the broker’s recorded ticks. Stop-loss and take-profit order inside a single bar, spread spikes and fast moves are only visible with real tick data.
If you use a strategy that depends on intrabar behaviour (scalping, breakouts, tight stops), always validate on real ticks, ideally from the same broker you will trade with.
3. Look-ahead bias and repainting
An EA that reads the value of the current, unfinished candle behaves very differently live, where that value keeps changing, than in the tester, which sees the final value. Repainting indicators (some ZigZag, fractal and pivot implementations) rewrite past signals, so a backtest looks perfect while live signals appear late or vanish. Requesting higher-timeframe data without care can also leak future information into the current bar.
- Base decisions on closed bars (shift 1) unless the logic truly needs the live bar.
- Avoid indicators that move past signals, or record the signal at the moment it was first produced.
- Run the EA on a demo account and compare each live entry with the tester over the same days; mismatched entries point to a look-ahead problem.
4. Overfitting (curve fitting)
Optimization finds the parameter set that fits the past best, including its noise. A strategy with many inputs, optimized on the full history, and chosen as the single “best pass” will almost always look better in the report than it will ever perform live.
- Keep the number of optimized parameters small.
- Reserve out-of-sample data the optimizer never sees, or use walk-forward analysis.
- Prefer a parameter plateau (neighbouring values also perform well) over a single sharp peak.
- Make sure there are enough trades for the result to be statistically meaningful; a few dozen trades prove very little.
5. Execution differs from the simulation
Live trading has latency, requotes, rejected orders, partial fills, minimum stop distances (stops level and freeze level), and swap charges. A VPS far from your broker’s server adds delay, and a different broker’s feed can produce slightly different candles and spreads than the history you tested on.
- Check
SYMBOL_TRADE_STOPS_LEVELand handle failedOrderSendcalls with sensible retries and logging. - Use the tester’s execution-delay setting to approximate latency.
- Run the EA on a VPS close to the broker’s trading server.
6. The edge belonged to one market regime
A trend-following system tuned on a strongly trending year will struggle in a range, and the reverse. If the test period covers only one regime, the equity curve says little about the next one. Test across several years that include trends, ranges, high and low volatility, and at least one major shock.
7. Money management hides risk
Grid and martingale systems produce smooth equity curves because they average into losers, until one long move triggers a margin call that wipes out months of profit. A backtest with a single survivable run can hide a very real risk of ruin. Look at maximum equity drawdown, the largest open lot size and margin level, not just net profit, and run the system with the deposit and leverage you will actually use.
A practical diagnosis checklist
- Re-run the tester over the exact days your demo or live account traded and compare trade by trade.
- Use real ticks, variable spread and your real commission.
- Stress test costs (+50% and +100% spread).
- Validate on out-of-sample data and across multiple market regimes.
- Inspect the code for current-bar reads, repainting indicators and unchecked order results.
- Forward test on demo for several weeks, then go live with a small size.
No test removes risk, and past performance does not predict future results. The goal is to find out why a strategy would fail before real money does.
Frequently Asked Questions
Why does my EA make money in the Strategy Tester but lose live?
The usual causes are unrealistic spread and commission in the test, low-quality tick data, look-ahead or repainting logic, overfitting to one period, execution differences such as latency and stop-level rejections, and a strategy that only suited one market regime. Each of these can be tested before real money is risked.
How can I tell if my backtest is overfitted?
Check whether nearby parameter values also work, validate on data the optimizer never saw or with walk-forward analysis, and make sure there are enough trades for the result to be meaningful. A single sharp optimum with few trades is a warning sign.
Does a better backtest guarantee better live results?
No. A backtest only shows how a strategy would have behaved in the past under the assumptions used. Realistic costs, real tick data, out-of-sample validation and a demo forward test make the estimate more reliable, but cannot remove risk.
Want an Independent Review of Your EA?
Send your EA or backtest report on Telegram or use the contact form. The initial consultation is free.