Skip to main content

Backtesting Mode

What it is

MT5 Backtesting Mode uses your broker's MetaTrader 5 environment to produce backtest results that account for real trading conditions — not approximations. Where Strateda's standard backtesting engine uses a simplified formula for quick signal evaluation, MT5 mode delegates profit, margin, and volume calculations to the MT5 Expert Advisor, which uses your broker's actual instrument specifications. The result is a backtest that reflects what would have actually happened if you had traded this strategy through your specific broker account.

This matters because trading costs vary significantly between brokers and instruments. A strategy that is profitable at one broker's spread may not be at another's. MT5 mode makes these differences concrete.

Plan requirement: Plus and above.

How to access it

  1. Ensure the Strateda EA is installed and connected in MT5 (see Expert Advisor Setup).
  2. Configure your strategy in Strateda as usual.
  3. In the backtest settings, select MT5 as the execution mode.
  4. Set your commission per lot (see Commission section below).
  5. Run the backtest. Strateda sends trade signals to the EA in batches, and the EA returns broker-accurate profit calculations.

What you see

The MT5 backtest produces the same equity curve, trade log, and performance metrics as a standard backtest — but the underlying calculations incorporate five broker-specific cost components:

Spread (3-tier historical system)

MT5 mode does not use a single fixed spread. It retrieves historical spread data using a three-tier fallback system:

  1. Tier 1 — Exact tick data: For recent trades (typically 1–3 months), the EA fetches real bid-ask tick data within a ±5 minute window of each trade's timestamp. This gives you the actual spread at the moment of execution.

  2. Tier 2 — Pattern-matched spread: For older trades where tick data is no longer available, the EA finds the same weekday and hour from the most recent available week. A trade from 3 months ago on Tuesday at 14:00 uses spread data from last Tuesday at 14:00. This captures daily spread cycles (wide during Asian session, tight during London/NY overlap) and weekly patterns (wider Monday opens, Friday closes).

  3. Tier 3 — Current spread: As a last resort, the broker's current live spread is used. This is the least accurate tier, especially if the backtest runs during off-hours while the trade occurred during peak hours.

An additional slippage multiplier (configurable in the EA settings) adds a percentage on top of the historical spread to account for execution costs. For example, a multiplier of 50% adds half the spread as an additional conservative buffer.

Commission

Commission is user-defined in the Strateda UI as a per-lot round-trip charge. You set this value based on your broker's commission structure:

  • 0 — For spread-only accounts (e.g., standard accounts where the broker's cost is embedded in the spread).
  • 7 — For raw spread accounts (e.g., $7 per standard lot round-trip).
  • Custom value — Any broker-specific per-lot commission.

The commission is applied per trade as volume × commission_per_lot. This is not read automatically from MT5 — you need to enter your broker's rate.

Swap

Overnight swap charges are calculated using your broker's current swap rates for the instrument. The EA applies the appropriate long or short swap rate based on the holding duration between trade open and close timestamps.

Important limitation: MT5 does not store historical swap rates. The system uses the broker's current swap rates for all trades, regardless of when they occurred. Brokers adjust swap rates frequently, so multi-month backtests may have some swap cost inaccuracy. This is a known limitation of all MT5-based backtesting.

Margin and position sizing

The EA uses MT5's built-in OrderCalcMargin() function to determine real margin requirements for each trade. Position sizes are calculated based on your configured position size (as a fraction of balance) and the broker's actual margin rates:

  • Margin budget = position size fraction × current running balance.
  • The EA uses binary search to find the largest volume that fits within this margin budget.
  • If the account cannot support a position at the required margin, the trade is reduced or skipped.

Balance compounds within and across batches — winning trades increase the next trade's margin budget, and losing trades reduce it, exactly as in live trading.

Volume constraints

Trades respect your broker's lot specifications, fetched from the MT5 symbol properties:

  • Minimum lot — Trades below this size cannot be placed.
  • Maximum lot — Trades are capped at this size.
  • Lot step — Position sizes are rounded down to the nearest valid increment (e.g., 0.01 lots). This means a portion of the margin budget may go unused due to rounding — realistic broker behavior.

Multi-instrument support

The EA handles all instrument classes transparently using MT5's built-in calculation functions. Forex, CFD, futures, indices, and crypto all use the correct margin and profit formulas without requiring instrument-specific configuration.

How to interpret it

Standard mode vs. MT5 mode

FactorStandard BacktestMT5 Backtest
SpeedFast — simplified calculationSlower — communicates with EA
SpreadNot modeled (defaults to 0)3-tier historical spread system
CommissionUser-defined flat valueUser-defined per-lot (same input, broker-accurate volume scaling)
SwapNot appliedCurrent broker swap rates applied
MarginSimplified leverage formulaBroker's real margin requirements via OrderCalcMargin()
Lot sizingUnlimited precisionConstrained to broker's lot step, min, and max
Profit calculationSimplified formula (accurate for signal evaluation)MT5 built-in OrderCalcProfit() (accurate for all instrument types)
CompoundingApplied via accumulated profitApplied with real balance updates per trade

When to use standard mode:

  • Early strategy development where you want fast iteration on signal logic.
  • Comparing strategy concepts across many instruments quickly.
  • When you don't have MT5 installed. The standard mode correctly shows whether a signal has an edge — use leverage=1 and posSize=1 to evaluate pure signal quality.

When to use MT5 mode:

  • Final validation before live deployment — you need to know the realistic P&L after all costs.
  • Testing on instruments with wide or variable spreads.
  • Evaluating whether a strategy survives your broker's specific cost structure.
  • When exact dollar figures matter (position sizing decisions, capital allocation).

Reading the cost gap

Run the same strategy in both modes and compare the equity curves. The gap between them represents total trading costs:

  • Small gap (< 20% of standard mode return) — Costs are manageable. The strategy's edge is large enough to absorb real-world friction.
  • Large gap (40–60% of return) — Significant cost drag. The strategy is profitable but costs consume a substantial portion of the edge. This is typical — a 40% cost drag on a genuine strategy is normal.
  • Gap eliminates profitability — The strategy's edge is thinner than the cost of executing it through your broker. Consider a broker with lower costs, a higher timeframe (fewer trades, less cost drag), or a different instrument with tighter spreads.

EA connections and backtesting speed

In MT5 mode, every profit and margin calculation is delegated to the connected EA. The EA processes these requests as they arrive, returning results to Strateda's backend before the next batch is sent. This communication happens sequentially — the backtest throughput is bounded by how quickly the EA can process and return calculation results.

More connected backtesting EAs means faster MT5-mode backtests. With multiple EA connections, Strateda distributes calculation requests across all available EAs in parallel, reducing total job time. This matters most for:

  • Large parameter optimization jobs — hundreds of parameter combinations, each requiring full profit recalculation across all trades
  • Walk-Forward Optimization jobs — multiple IS/OOS windows, each running a full MT5-mode backtest

For a standard single backtest the difference is small. For a 200-combination optimization or a 7-window WFO job in MT5 mode, additional EA connections meaningfully reduce the time waiting for results.

Backtesting EA connections by plan:

PlanBacktesting EA connections
Free0 (MT5 mode not available)
Plus1
Pro1
Premium2

Backtesting EA connections are a separate limit from live strategy EA connections. A Premium user can have 2 backtesting EAs and 4 live strategy EAs connected simultaneously.

tip

To take full advantage of Premium's 2 backtesting EA connections, attach a second EA instance to a chart in MT5 and set its EA Type to Backtesting. Both EAs will share the calculation workload for large optimization and WFO jobs.

Example

A trader develops a DEMA/EMA crossover on EURCHF M30 using standard backtesting. The results show approximately +9% return over 2 years.

They then run the same strategy in MT5 mode through their broker (raw spread account, $7 per lot commission):

  • Spread impact: Historical spread reveals EURCHF spreads of 0.5–1.2 pips during London hours and 1.5–3.0 pips during the Asian session. Many of the strategy's best trades execute overnight, where spreads are widest.
  • Commission: At $7 per lot, commission adds approximately 0.7 pips equivalent per round trip.
  • Swap: Overnight holds accumulate swap charges on approximately 60% of trades.

The MT5 backtest shows approximately +5.5% return — a 40% cost drag. The strategy remains clearly profitable after all real-world costs. The trader now has realistic expectations for live performance and can deploy with confidence that the backtest-to-live gap will be small.