Testing and analysis
Forex Backtesting Costs: Model Spreads Without Duplication
Published Updated ForeXpert team日本語で読む

The first step in reviewing forex backtesting costs is to identify which prices your test uses and which charges are already included. A midpoint-only calculation needs different adjustments from a record based on bid and ask executions. Adding a generic spread deduction to both can count the same cost twice.
This guide separates the main cost categories, works through fictional examples and provides a review sequence. The goal is to understand how sensitive a result is to its assumptions, while keeping confirmed inputs distinct from anything the test does not model.
The main forex backtesting costs to check
The spread is the difference between bid and ask. The bid is the price at which you sell; the ask is the price at which you buy. OANDA's official explanation describes these two sides of the quote.
A long trade therefore enters at ask and exits at bid. Even if the market's reference price is unchanged, opening and immediately closing the position does not normally produce zero before other charges. You transact on opposite sides of the quote.
| Category | What to identify | Common accounting problem |
|---|---|---|
| Spread | Difference between bid and ask | Deducting it again after using bid/ask fills |
| Commission | Charge per side or round trip | Treating a per-side fee as the full cost |
| Financing or swap | Holding-related payments or credits | Omitting applicable holding periods |
| Execution differences | Difference between assumed and filled prices | Treating a fixed adjustment as a complete model |
These are general categories, not a quotation of any provider's current fees. Check the applicable contract and pricing documents if you need actual charges. Spreads can also change with market conditions, as explained in OANDA's spread guidance. A constant spread is a modeling assumption, not a full reconstruction of every historical quote.
Bid, ask and midpoint require different treatment
The midpoint is the average of bid and ask. Before calculating a result from a chart, determine whether its candles represent midpoint, bid, ask or something else. A price chart alone does not necessarily tell you both executable sides.
Consider a fictional EUR/USD quote of 1.1000 bid and 1.1002 ask, with a position of 10,000 euros. Buying at 1.1002 and immediately selling at 1.1000 gives (1.1000 − 1.1002) × 10,000 = −$2. This excludes commission, financing and execution differences.
That $2 is already reflected in the two fill prices. Subtracting another $2 spread charge would count it twice. A calculation that assumes both transactions occurred at the 1.1001 midpoint instead produces zero, so it requires an adjustment for the missing spread effect.
A simplified midpoint model
For a long trade with the same quantity at entry and exit, let the spreads be s₁ and s₂. Relative to midpoint prices, the spread effect is (s₁ + s₂) ÷ 2 × quantity. With a spread of 0.0002 at both ends, this is (0.0002 + 0.0002) ÷ 2 × 10,000 = $2.
Do not automatically deduct a full spread twice merely because there are two transactions. Equally, do not copy this midpoint formula into a bid-only test without checking its assumptions. The adjustment depends on the reference prices and the fill model.
Check the profit currency and account-currency conversion as well. A pip's monetary value depends on the instrument, quantity and conversion basis. Conventions used for ordinary currency pairs should not be assumed to apply unchanged to metals or every symbol a tool provides.
Worked example: change the cost assumption
Suppose a fictional set of 100 completed trades produced $200 before any modeled costs. All trades use the same quantity. We apply a constant additional round-trip charge to each and assume no further financing or execution differences. These figures are illustrative and do not describe an actual account.
| Round-trip cost per trade | Total cost for 100 trades | Adjusted total | Average per trade |
|---|---|---|---|
| $1 | $100 | $100 | $1 |
| $2 | $200 | $0 | $0 |
| $3 | $300 | −$100 | −$1 |
The formula is adjusted total = pre-cost total − trade count × round-trip cost. For the $3 case, 200 − 100 × 3 = −$100. A small pre-cost average can therefore change sign under a modestly different assumption.
This aggregate calculation does not reveal the adjusted win rate or profit factor. Recalculate each trade, then classify it again. A small winning trade can become a losing trade after charges, changing both sides of the profit-factor calculation. Subtracting every cost from the old profit total alone would miss that effect.
Four steps to review the cost model

1. Identify the price series
Read the data or tool documentation and establish whether the test uses bid, ask, midpoint or execution prices. If the answer is unknown, record that limitation instead of describing the result as fully cost-adjusted. Candle highs and lows may not reconstruct the executable quote at a particular instant.
Keep this information with the test rather than relying on memory. A later comparison is easier to interpret when the file clearly identifies its data basis, instrument, quantity and reporting currency.
2. Mark costs already included
Create a short list separating embedded costs from additional charges. A trade history whose net results already subtract commission should not have that same commission deducted again. Likewise, bid/ask fills and a midpoint model need different spread accounting.
Record labels such as “spread included in fills” or “commission applied separately.” This is a bookkeeping step, but it prevents a sophisticated-looking sensitivity analysis from starting with the wrong base result.
3. Document missing charges and execution limitations
Check whether a quoted commission is per side or round trip and whether its basis changes with quantity. Record whether positions cross financing times. If holding-related charges are omitted, state that explicitly rather than assuming they are negligible.
Execution differences can be favorable or unfavorable, but an optimistic assumption is not evidence that it will occur. TradingView's strategy documentation discusses commission and slippage modeling. Any simplified adjustment still has limits: it cannot guarantee a particular fill or fully reproduce every market condition.
4. Compare the same trades under alternative assumptions
Reprice the completed record using clearly stated cost cases, then rebuild average outcome, win rate and profit factor. Preserve all cases. The purpose is to find where the conclusion depends on a narrow assumption, not to select whichever fee estimate leaves the best result.
Our guides to trading expectancy and profit factor explain how to interpret the recalculated measures. Keep the trade count and the reporting currency beside them.
Pasting the results of each cost case into our backtest results calculator gives you average result, profit factor and win rate side by side.
There is an important limit to post-processing. A wider spread can change whether an order fills or when a stop is reached. If that matters, subtracting a charge from an unchanged trade list is insufficient; you need to rerun the execution logic as well. Label the first exercise as a cost sensitivity check and distinguish it from a full execution-aware retest.
ForeXpert supports historical decision practice and performance review. The comparison table described here is a separate worksheet exercise; it is not a claim that the app reproduces every live trading cost. Keep any unverified assumptions visible alongside the app's displayed statistics.
Frequently asked questions
Is an average spread enough?
It can be a simple baseline, but it does not describe every time of day or market condition. Compare a wider-spread case and document how the conclusion changes. Do not describe that case as a proven historical maximum unless you have the supporting data.
What if the result becomes negative after costs?
First check for missing charges and duplication. If the assumptions are correct, retain both the original and adjusted records. Do not keep changing rules on the same period until a positive result appears. Write the reason for any revision and evaluate unchanged rules on another period.
Summary
Identify the price basis, separate included and additional costs, and recalculate outcomes trade by trade. Add these checks to the preparation stage of the five-step backtesting process.
Backtest results do not guarantee future performance, and live trading involves loss risk. A useful cost model makes its assumptions and missing information visible, so that its results can be reviewed honestly.


