Blog

SQX vs MT5 Backtest Results: Why They Differ and How to Narrow the Gap

You export an expert advisor (EA) from StrategyQuant X (SQX), run it in the MetaTrader 5 (MT5) Strategy Tester, and the SQX vs MT5 backtest results do not match. Sometimes the difference is small. Sometimes even the trade count is different.

This is rarely one bug. It is usually several small differences between two programs that each make their own assumptions. This article lists them in the order they most often matter, with a checklist at the end.

The aim is not an identical equity curve. The aim is to explain every difference you can see in the trade list.

1. Start with the data and the precision mode

Most gaps begin here, because the two programs may not be reading the same prices.

Different feeds. SQX is often fed third-party data or an import from a terminal. MT5 tests against the history of the broker server you are logged in to. SQX's guide to reliable backtesting says broker data will differ from third-party data and suggests treating that as a robustness test. It also gives the cleanest diagnostic: export data from MT5, import it into SQX, and confirm the backtests match on identical data.

Different tick models. SQX documents four precision modes: Selected Timeframe Only (four ticks per bar from open, high, low and close), 1-Minute Data, Real Tick with a custom spread, and Real Tick with the real spread. MT5 offers Every tick, Every tick based on real ticks, 1 minute OHLC, Open prices only and Math calculations. In MT5's generated modes the ask is the bid plus the fixed spread of that minute bar. If the two models differ, a stop and a take-profit inside one bar can resolve in a different order, and a different order is a different trade.

Holes in the history. When testing on real ticks, MT5 treats minute data as the more reliable source and generates ticks for a minute bar that has no tick data. A minute that is missing altogether is different: a simulation built from M1 bars has no path through it, so a stop inside it fills at the next price that exists. If one program's history has holes the other's does not, trades near them will differ.

Stale cache in SQX. SQX caches backtest data in memory and on disk. Its guide says the cache can be outdated after you import data or change settings, and recommends exiting SQX, deleting the files in the internal testfiles folder, and restarting.

2. Spread, slippage and execution assumptions

Next most common is a cost you set in one program and forgot in the other.

Spread. In SQX the spread is something you define, in pips, unless you use the real-spread mode. A connected MT5 uses the live spread, so results can change between runs; the SQX guide describes disconnecting the terminal from the network before testing. That guide is dated 2019, so check the procedure against your build. At minimum, write down the spread each test used.

Slippage. SQX adds slippage, in pips or ticks, to entry and exit prices. The closest MT5 tester setting is execution delay: none, random from 0 to 9 seconds, or fixed. These model the same real-world effect differently. For a fair comparison, use zero slippage and no delay in both, so execution is not hiding another cause.

Order types. Market orders are the easy case. Stop and limit orders depend on the tick path. MT5's documentation says that in Open prices only mode, stop levels and pending orders may trigger at different prices, and that the mode suits quick, rough tests. SQX says a strategy that is profitable at lower precision may stop being profitable at higher precision, because lower precision is less exact. Use the same fidelity on both sides before comparing.

3. The clock: broker timezone and daylight saving

Time problems look like a different number of trades, or entries one bar from where you expected them.

SQX stores a timezone with the data, and its broker profiles let you set your broker's timezone; downloaded data is converted from the source's timezone to that one. MT5 runs on the server's clock. Some broker servers use an offset from UTC that moves with US daylight saving, so check yours: the offset may not be one number for the whole year.

That matters for anything that depends on the hour or the day: session filters, exit at end of day, Friday closes. The SQX guide says to use the same timezone as your broker, especially for those features. It also says to choose the "Timestamp is start of bar time" bar type when importing from a file, because MT5 uses it and it affects how higher timeframes are built. SQX's broker-profile page does not say how daylight saving transitions are handled, so do not assume it. Test it.

A practical test: find the first bar after the weekend gap on a forex pair, in both programs, in a winter week and a summer week. If the two differ by an hour in one season and not the other, you have a clock problem, not a strategy problem.

4. Costs, symbol rules and indicator builds

These are smaller on most symbols, but they explain a persistent, uniform offset.

Swaps. MT5 describes several swap models: points, money in base, margin, deposit or profit currency, and annual interest on the current or open price, plus a weekday for the triple swap. SQX describes points, fixed money and percentage. If your broker's swap is in one unit and your SQX instrument is set in another, the overnight cost differs. Short-term strategies barely notice; multi-day ones do.

Commission. MT5's symbol specification describes commission charged per lot or per deal, with tiers that can depend on volume or turnover. Check whether yours is charged once or per side, and that both programs apply it the same way.

Tick size, point value and session. SQX keeps its own description of each instrument. A broker profile can override point value and tick step. SQX's broker-profile guide notes that point values from its script are calculated in USD, so with another account currency you must update them by hand. If they differ from the terminal, the same lot is worth a different amount.

Minimum stop and freeze levels. An MT5 symbol can carry a minimum distance for stops and pending orders, and a freeze distance inside which they cannot be modified. SQX has its own minimum distance for pending orders. A strategy with tight or trailing stops can lose trades, or have modifications refused, on the MT5 side only. Some brokers may show zero and enforce a spread-based minimum instead, so check the live rules.

Lot rounding. MT5 publishes a minimum volume and a volume step per symbol. If sizing comes from risk or equity, a computed size that falls off the step may be rounded or rejected, and sizes that round differently give different profit per trade.

Indicators. The SQX guide notes that custom indicators must be imported into MT5 or the strategy will not run correctly. Differences in how a smoothed indicator is seeded, or how many warm-up bars it needs, can shift a signal by a bar early in the test. Compare indicator values on the same bar before comparing anything downstream.

5. A checklist to compare SQX and MT5 backtest results

Compare trade lists, not equity curves. One early difference makes everything after it diverge, so the curves look unrelated even when one trade is responsible.

  1. Make the inputs identical. Same symbol, dates and strategy settings, and a fixed lot size for this test.
  2. Use the same data. Export M1 history from MT5, import it into SQX, and test on that.
  3. Match the model. Use the highest comparable fidelity in each program, and write down the mode names.
  4. Zero the soft assumptions. No slippage, no delay, an explicit fixed spread in both.
  5. Export both trade lists with entry time, exit time, direction, size, entry price and exit price.
  6. Find the first difference. Sort by entry time and find the first trade that is missing, extra or different. Ignore what follows.
  7. Classify it. An hour off points at the clock. A few points off points at spread, slippage or the tick model. A missing trade near a stop points at stop levels or the tick path. A size difference points at lot rounding or symbol specs.
  8. Fix one thing and rerun. The first difference moves later as causes are removed.
  9. Restore realistic costs last, then compare again.

If the programs will not match on identical data, clear the SQX cache described above first.

Where AlphasWorth fits

AlphasWorth makes add-ons for SQX, and two of them touch causes above. Fix the cause first; decide about tools afterwards.

GapSmith is free (a key is sent to your email). It adds a Fix gaps button to SQX's Analyze data quality view, shows how many M1 minutes are missing before it writes anything, and by default imports the result as a new symbol with a _patched suffix, leaving the original untouched. It fills flat bars by default (an optional, marked synthetic fill goes to a separate _synth symbol) and cannot recover prices that were never recorded, so test on both versions. The paid News module reads the calendar from your MT5 terminal and measures the timezone offset it was written in, using releases whose New York time does not move, so SQX and MT5 read the same event file.

AlphasWorth is independent of StrategyQuant and MetaQuotes. Product names are used only to describe compatibility.

Frequently asked questions

Should SQX and MT5 give exactly the same result?

No. On identical data and settings they should be close, and every difference should trace to a trade you can point at.

Which result is correct?

Neither is the truth. The one nearer your broker's data and symbol rules is more useful. Neither predicts live results.

Why is the gap larger on small timeframes?

Short-term strategies depend on what happens inside a bar, so the tick model, spread and slippage matter more.

Does matching the two backtests mean the strategy will work live?

No. It means the two simulations agree. It says nothing about future results.

Sources

Risk

Trading leveraged instruments carries a high risk of loss. Software output is not investment advice and says nothing about future results.