In this article
After this article, you can
- Reconcile an Ask/Bid result with a midpoint model.
- Identify double-counted spread in a report.
Terms at hand: bid and ask (bid-ask prices) · spread (bid-ask spread) · Backtesting · Central banks · Commission · Drawdown
A high historical win rate alone does not establish an edge. A backtest evaluates explicit rules on defined data under an execution model; even a careful test does not guarantee future returns.
Why test a strategy on historical data at all?
Positive historical expectancy is evidence about the tested sample. It can reflect chance, selection or overfitting, so evaluate withheld data, costs and robustness before drawing wider conclusions.
Rules must be unambiguous, or you are testing fiction
Record the symbol, timeframe, signal inputs, order timing, exit rules and position-sizing calculation. For a hypothetical daily rule, compare the completed bar’s close with the previous bar’s high, then send an order only after that close becomes available. Using the final close to enter at the earlier open of the same bar would introduce future information. Specify what happens with an existing position, unavailable data or insufficient margin. An indicator setting alone does not resolve these decisions or guarantee a fill.
A related topic is how to discover a trading edge: a historical test can reveal a contradiction in the proposed rules, but a positive result still needs evaluation of costs, selection and uncertainty. For broader context on testing within the working trader’s routine, see the trader’s workshop in our library.
Where to get historical data and how many samples are enough?
Select data that match the intended instrument and execution model. Currency futures and OTC spot or CFDs are different contracts; centralized futures data are not automatically an adequate substitute for a retail spot strategy.
There is no universal statistical-significance threshold of 100 trades. Required evidence depends on dispersion, dependence, effect size, selection and regime coverage. Report uncertainty and effective sample size.
Choose a research period covering relevant conditions and document its limitations. Record the provider, product, quote side, time zone and gaps. OHLC alone does not identify the order of a stop and target touched inside the same bar. MT5 can generate ticks for a minute bar lacking tick history even when testing from real ticks; check the dataset and journal rather than relying on the mode’s name. For an instrument basket, retain the selection available at the time, and use macro releases available then rather than later revisions.
Reconcile prices before charging the spread
Entry Ask and exit Bid account for the spread differently from a result measured between quote midpoints. Compare them in one complete example.
Scroll sideways to see the full diagram
Assumptions: Two hypothetical simultaneous Bid/Ask quotes for the same fictional instrument: entry 100/102, exit 103/105. Midpoint is the average of both sides. One arbitrary quantity unit; execution exactly at the assigned Ask and Bid. No fees, financing, gaps or slippage. These are not current FX quotes or guaranteed fills.
Execution exactly at the assigned prices gives 103 − 102 = +1. Quote midpoints change by 104 − 101 = +3. Entry is 1 above the midpoint and exit 1 below it: 3 − 1 − 1 = +1. Both methods reconcile this model.
Full spreads are 2 at entry and 2 at exit. Subtracting both full spreads from the midpoint change gives 3 − 2 − 2 = −1, inconsistent with these executions. Subtracting 2 from 103 − 102 would be another double charge, because that result already uses Ask and Bid.
MetaQuotes — Bid and Ask trading prices distinguishes the chart-building price from operation prices. Record each price’s source before comparing reports. This calculation uses one quantity and price unit; additional fees or other executions require a separate model.
Spread, commission and slippage — without them the backtest lies
Costs depend on the product and execution model. Entry at Ask and exit at Bid already include the spread in the price result; subtracting it again would double-count it. Add any separate commissions, financing and stated execution differences. A hypothetical 0.8-pip spread is 0.4% of a 200-pip target and 16% of a five-pip target. Those are shares of target distance, not of the strategy’s edge, and neither comparison estimates a real trading result.
In a separate hypothetical example, 50 closed trades produce 30 gains of PLN 40 and 20 losses of PLN 50 before costs: gains PLN 1,200, losses PLN 1,000 and net PLN 200. Assign the same full cost to every closed trade, including losses.
| Cost per trade | Net total | Net mean | Net profit factor |
|---|---|---|---|
| PLN 0 | PLN 200 | PLN 4 | 1.20 |
| PLN 2 | PLN 100 | PLN 2 | About 1.10 |
| PLN 4 | PLN 0 | PLN 0 | 1.00 |
With a PLN 2 full cost, each gain becomes PLN 38 and each loss PLN 52: profit factor is 1,140 / 1,040, about 1.10. The table changes only this assumed cost; it is arithmetic, not evidence about an observed strategy.
Stress plausible costs and execution changes. A two-times-average-cost rule is a chosen screen, not a universal safety margin or proof of profitability.
A curve fitted to history is not a strategy — it is a museum
Choosing the best of many parameter values, instruments or sample splits can fit peculiarities of the observed history. Record all trials, including discarded ideas outside the optimiser. A strong selected result alone does not establish that this happened, but it needs a separate evaluation. Limiting optimisation to two parameters does not remove selection introduced elsewhere.
Freeze the split before tuning and reserve data for evaluation. A 70/30 split is one possible design. A weaker test result can reflect regime differences or sampling as well as overfitting. Revising the strategy after inspecting this test turns it into development data; document that use.
Chronology also depends on when each outcome becomes known. In a hypothetical model, a decision at t is labelled at t + 3. The first test begins at t 10, and fitting must finish before then. Of candidate decisions t 1–t 9, only t 1–t 6 have outcomes available before t 10. Decision t 6 is labelled at t 9; t 7–t 9 are labelled at t 10–t 12 and cannot inform this fit. Earlier prices may still be needed to calculate a test indicator. This exclusion resolves the stated label overlap, not every possible source of leakage.
A hypothetical example — how to read the numbers honestly
Hypothetical arithmetic: with win probability 0.54, mean win 2.3R and mean loss 1R, gross expectancy is 0.54 × 2.3 − 0.46 = 0.782R and profit factor is about 2.70. These assumptions do not establish a drawdown or total return. Separately, an assigned 87% return over exactly five years compounds to about 13.34% annually; it is not derived from these trade statistics.
What to do tomorrow
Use the following checks to connect the report with an identifiable dataset, rule version and execution model. Reproduce individual trades, including a loss, a missing signal and an ambiguous intrabar case. A demonstration run can test operation in real time; it does not require a move to a live account after a positive result.
- Write the strategy in a single text file, mechanically. Specify when information becomes available, the order and sizing calculation, and how ambiguous or unavailable inputs are handled. Compare independently reproduced signals and investigate differences before relying on the aggregate result.
- Specify data duration and a chronological training/test split before tuning. Duration should fit the strategy and available evidence; five or two years is not a universal requirement.
- Include spread, commission, financing and stated slippage assumptions, then test sensitivity. Losing more than 20% of gross profit to costs is not a universal rejection threshold.
- Record trade count, dependence, dispersion and uncertainty. Adding history or instruments changes the sample and may change the strategy hypothesis; 100 trades does not automatically establish significance.
- Compare demo behavior with the frozen model and investigate discrepancies. Three months of demo observation does not guarantee readiness or earn a right to profitable live results.
Check your understanding
One short exercise
About 2 min · you can try again
Long entry is exactly at Ask 102 and exit at Bid 103. With no other costs, what is the result for one quantity unit?
- +1 result unit; spread is already included in the two execution prices.
- −1, because spread 2 must still be subtracted from the price difference.
- +3, because quote midpoints rise from 101 to 104.
Check the answer and explanation
+1 result unit; spread is already included in the two execution prices.
103 − 102 = 1. Do not subtract again the spread already present in the selected quote sides.
Frequently asked
What is strategy over-fitting?
Overfitting means adapting a model to features of the development sample that do not generalise to new observations. A win rate alone cannot diagnose it: inspect the gain/loss distribution, costs, selection history and genuinely withheld data. Revising rules after seeing a test result makes that period part of development.
Which software should I use for backtesting?
Choose a tool that can represent the intended rules, product, data and execution assumptions. MT5’s Strategy Tester supports Expert Advisors, multi-symbol testing and several tick modes. Verify the available history and record the settings. Manual replay and coded testing answer different operational questions; neither prevents future information or unrealistic fills by itself. Compare current vendor documentation rather than assuming a fixed price or a universal platform ranking.
How much historical data do I need for an honest test?
There is no universal number of years or trades. Consider dependence between outcomes, dispersion, the conditions the strategy is meant to cover and the number of ideas tried. More symbols can change the hypothesis rather than merely increase evidence. State the sample’s limits and keep a chronological evaluation whose outcomes were unavailable during development.
What do realistic results from a good backtest look like?
There is no single realistic win-rate, profit-factor or drawdown band for every strategy. Reconcile net outcomes, exposure, open-position equity, costs and all selection trials. For example, the article’s hypothetical 50 trades fall from PLN 200 to zero when the full cost rises from PLN 0 to PLN 4 per trade. That calculation illustrates sensitivity; it does not validate a live strategy.
Sources & bibliography
-
MetaQuotes Strategy Testing in MetaTrader 5 · Official MT5 documentation of historical strategy testing and optimization. www.metatrader5.com ↗
-
MQL5 Reference Testing Trading Strategies · MQL5 developer documentation discusses tick generation, spread modeling and multisymbol testing. www.mql5.com ↗
-
Bank for International Settlements OTC foreign exchange turnover in April 2022 · The April 2022 survey provides FX market-structure data as context for retail-instrument backtesting. www.bis.org ↗
-
MetaQuotes Real and Generated Ticks · MT5 documentation distinguishes Bid/Ask operation prices, real-tick spreads and generated ticks used when minute bars lack tick data. www.metatrader5.com ↗
-
scikit-learn Common pitfalls: data leakage · Developer documentation explains how unavailable future information and test-data preprocessing can bias evaluation; its example is synthetic, not a trading study. scikit-learn.org ↗
-
scikit-learn TimeSeriesSplit · API documentation describes chronological indices and a gap counted in samples; variable-duration trading outcomes still require explicit availability checks. scikit-learn.org ↗
