The average spread is not your robot's average cost
Measure execution costs at the moments a strategy acts, distinguish time and trade weighting, and stress costs jointly with signal activity.

The market was cheap until the strategy wanted to trade
An analyst downloads a spread history, calculates its average and inserts that number into a backtest. The result appears comfortably positive after costs. Later, the analyst places the robot’s signal times over the same history and discovers a different picture: most signals occur during the comparatively expensive intervals. The market’s average condition was not the average condition encountered by the strategy.
This fictional investigation is about sampling, not about a particular broker or robot. A strategy selects the moments at which it pays costs. If the selection is related to market conditions, a time-weighted average can be a poor substitute for a strategy-weighted cost estimate. The error can persist even when the underlying spread data are accurate and the arithmetic used to average them is correct.
We will work through hypothetical examples that isolate time weighting, signal activity, quantity weighting and joint stress. None of the numbers is an estimate for TradeAndRoll systems. The aim is to build a cost model that corresponds to a clearly defined research question, and to understand what remains unknown when the available data contain only a simplified view of execution.
The useful question is not whether one constant cost is always forbidden. A constant can be an intentional diagnostic or a rough sensitivity input. The question is whether its meaning is explicit and whether the conclusion depends on assuming that the strategy samples costs independently of the conditions that trigger its activity. Making that assumption visible can change the next experiment more than adding another decimal to the reported return.
Define the cost before choosing its average
The bid-ask spread is the distance between two quoted prices at a particular moment. It is not automatically the complete economic cost of a round trip. Commissions, adverse or favorable price movement during execution, financing, conversion and unfilled activity may require separate treatment. The accounting depends on the price convention used by the backtest and on what the research intends to compare.
Suppose a simplified simulation values a buy and a later sell against the midpoint at their respective times. With immediate execution at the displayed ask on entry and bid on exit, the spread contribution is half the entry spread plus half the exit spread, before other effects. If both spreads are equal, this equals one full spread over the round trip. If they differ, applying the entry spread twice or assuming the exit is identical can misstate the cost.
For example, hypothetical entry and exit spreads of 2.4 and 3.2 pips imply a midpoint-relative spread contribution of 1.2 plus 1.6, or 2.8 pips. This is a deliberately simplified quote-based calculation. It does not assert that every intended quantity can be executed at those prices, or that a historical quote reveals the fill the strategy would have received.
Write the price convention beside the cost convention. If the simulated trade already uses bid and ask prices, subtracting another full spread may double count. If it uses midpoint prices without adjustment, ignoring spread may omit a material term. Before studying whether costs depend on signals, make sure that the same cost is neither absent nor included twice.
Keep gross and net results reconcilable. The report should show which terms convert the gross reference-price result into the net result under the chosen model. This makes later stresses interpretable: increasing a spread term, changing an execution delay and adding financing are different interventions. Combining them can be appropriate, but their effects should remain traceable rather than disappearing into an unexplained generic fee.
There is a further distinction between a cost adjustment and a change to the prices that generate signals. If an indicator uses midpoint bars while the intended implementation uses a different quote side, the signal timestamps may change. Subtracting a fee from the original trades does not investigate that change. The researcher must decide whether the exercise holds the signal process fixed or reconstructs it under the intended price convention. Both can be legitimate, but they answer different questions and can produce different opportunity populations.
Signal prices and execution prices need separate definitions. Store the reference used to compute a signal and the reference used to value its execution. A price can be suitable for an indicator without being an executable quote, and an executable quote can arrive later than the information used by the signal. Separating those fields helps prevent an accidental mixture of idealized decisions and realistic costs. It also makes a later disagreement easier to diagnose: the difference may originate in the signal, the fill assumption or the cost calculation rather than in the strategy’s underlying logic.
The time-weighted average answers a different question
Imagine 100 equal-duration observation intervals. Eighty are labelled quiet and have a hypothetical spread of 0.8 pips. Twenty are labelled active and have a spread of 2.4 pips. Averaging equally over time gives 0.8 times 80% plus 2.4 times 20%, or 1.12 pips. That number correctly describes the average spread at a uniformly selected interval in this invented archive.
Now suppose a strategy generates 100 equal-sized round trips, with 20 assigned to quiet conditions and 80 to active conditions. For this isolated example, assume each round trip has equal entry and exit spreads within its assigned state and no other costs. The strategy-weighted average spread cost is 0.8 times 20% plus 2.4 times 80%, or 2.08 pips. Both averages are correct; they describe different sampling distributions.
The difference is not a minor rounding issue. Suppose each pip is worth USD 1 for the hypothetical fixed quantity and account convention. Applying the time average to 100 round trips gives USD 112 of spread cost. Applying the stated trade distribution gives USD 208. The difference is USD 96. We have changed no quote and no gross result; we have only matched the cost weights to the strategy’s activity.
If the gross result is an invented two pips per round trip, total gross profit is USD 200. The time-average model reports USD 88 net, while the activity-weighted calculation reports negative USD 8. This does not show that a real strategy is unprofitable. It shows that a sampling mismatch can change the sign of a hypothetical conclusion even before more complex execution effects enter the model.
Average the costs over the population your question actually concerns. A market description, a signal description, an executed-trade description and a notional-weighted description can all be useful. They should not share an unlabeled “average spread” column as though they were interchangeable quantities.
The signal ledger starts before the executed trade
A ledger containing only successful fills may hide the most difficult opportunities. Some signals may be rejected by an execution condition, delayed until a different price or skipped because a resource constraint is active. If those events disappear from the archive, the observed average cost describes the surviving executions rather than the full policy that generated the attempts.
Preserve candidate opportunities with stable identifiers and timestamps. Record the signal state available at that moment, intended quantity, relevant quote, eligibility decision and eventual execution outcome. The fields should distinguish no signal, a rejected signal, a permitted but unfilled attempt and an executed position. These categories answer different questions and should not be collapsed into a zero-cost observation.
For a cost diagnostic, it may be useful to evaluate all candidate signals against a common quote convention. For a policy evaluation, it may be necessary to replay the actual rules that decide whether and how a signal becomes a position. An opportunity-level diagnostic and an executed-policy result are different objects. The first can reveal exposure to expensive conditions; the second includes the consequences of acting or not acting under constraints.
A rejected opportunity does not automatically have an economic loss equal to the profit it would have made in hindsight. The counterfactual fill and subsequent path may be unknown. It is better to report the rejection and its conditions than to invent a precise missed-profit figure. If a counterfactual simulation is used, state the assumptions that make the hypothetical execution possible.
The same ledger helps evaluate a spread filter. A filter may remove expensive opportunities, but it can also change the sample of gross outcomes, capacity available for later signals and the timing of exposure. A lower average cost among the remaining trades is not enough to establish a better net policy. The article on component ablation explains why removing a condition can change the population being compared.
State dependence needs measured conditions, not hindsight labels
A cost model can condition on variables such as the observed spread, session, recent volatility or current activity. The variables must be defined using information available when the model would use them. A label that calls an interval stressful because its future realized range was large is not necessarily a state available to the strategy at the decision time.
There is a legitimate difference between retrospective explanation and prospective modelling. Looking back at an event can help explain why costs were unusual. Using that explanation as a predictor requires a rule that could have identified the relevant condition beforehand or at the time. Preserve that distinction when an AI assistant suggests a clever classification after reading the complete price path.
OANDA’s own documentation states that its spreads can widen with volatility and changes in liquidity, including around news and market openings or closings. This is a broker-specific illustration that quoted costs can depend on conditions, not a universal schedule or an estimate for another provider. OANDA: market conditions and spreads. A strategy study still needs data and conventions appropriate to its intended environment.
Conditioning variables should be reproducible at the decision time. Define their window, timezone, update frequency and handling of missing observations. If a volatility estimate uses a rolling window, specify whether the current unfinished interval is included. If activity is measured from the strategy’s own signals, distinguish signals known at that moment from the total number that will occur later in the session.
Start with a small number of interpretable conditions. Creating dozens of tiny groups can produce unstable cost estimates and attractive stories from sparse observations. Inspect counts, quantities and coverage in each group. A coarse model with visible limitations can be more useful than a highly detailed map whose most important cells contain only a few events.
Quantity weighting can reverse another apparently simple average
Equal weighting by trade answers the cost of an average trade under a specified trade definition. It does not necessarily answer the cost per unit of exposure. A small trade and a large trade may have different economic importance, and splitting one trade into several records can change an unweighted mean without changing the underlying execution.
Consider two hypothetical round trips in a dollar-quoted pair under a convention where 10,000 base units imply USD 1 per pip. The first uses 10,000 units and has a cost of 0.8 pips, or USD 0.80. The second uses 30,000 units and costs 2.4 pips, or USD 7.20. The total is USD 8 across 40,000 units. The equal-trade average is 1.6 pips, while the quantity-weighted average is 2.0 pips.
The difference comes from the larger quantity encountering the higher cost. It does not require market impact to exist in the example; the assigned prices already create the weighting difference. If the quantity itself affects the available execution price, that introduces another mechanism that must be modelled or left as an explicit limitation. A displayed spread for a small quantity may not establish the cost for every larger quantity.
Keep counts, quantities and money in separate columns. A useful report can show the average cost per event, per unit and in total currency without confusing them. It should also specify whether partial fills are separate observations or parts of one parent opportunity. Otherwise a reporting choice about how fills are split can masquerade as an improvement in the strategy’s execution economics.
For cross-pair comparisons, pip values and currency conversion need explicit treatment. A pip is a quoting unit, not a universal amount of account money. Convert through the appropriate contract and account conventions before aggregating. If those conventions are unavailable, preserve the native units and state that a complete portfolio cost comparison has not yet been established.
The same total cost can still produce a different path
It is important not to overstate what dependence changes. If a fixed set of equal-sized trades receives exactly the same collection of additive costs, merely reordering those costs does not change their sum. With gross outcomes also fixed and no state-dependent decisions, the terminal net total remains unchanged. Claiming that every cost reshuffle must change expectancy would confuse a change in timing with a change in the total amount paid.
Timing can still matter. Consider two hypothetical gross outcomes, negative USD 100 followed by positive USD 120, with initial account value USD 1,000. Assign costs of USD 20 and zero in that order. The net outcomes are negative USD 120 and positive USD 120, taking the account to USD 880 and then back to USD 1,000. The observed drawdown at those checkpoints is 12%.
Reverse the same two costs. Net outcomes become negative USD 100 and positive USD 100. The account moves to USD 900 and returns to USD 1,000. Total cost and terminal value are unchanged, but checkpoint drawdown is 10%. These are invented two-step paths, not estimates of actual risk. They show that cost concentration can alter path metrics without changing total cost.
If the policy reacts to drawdown, resource use or previous outcomes, the later decisions can differ as well. Then even the terminal total may change because the set of executed positions is no longer fixed. That is a stateful policy effect, not a contradiction of the additive identity. A rigorous report identifies which experiment it ran: fixed-trade accounting, quantity changes or a complete policy replay.
This distinction improves stress design. A cost permutation can be a useful control for timing dependence, while an increased cost level tests a different question. Combining both is possible, but the report should not attribute every change to correlation. Separate the amount paid, the moments paid and the decisions changed. Those three mechanisms can have different consequences and different evidence requirements.
Stress activity and costs together with a small scenario grid
A uniform cost multiplier asks what happens if every assigned cost increases proportionally. That can be a useful sensitivity check, but it does not necessarily represent a change concentrated in the states where signals cluster. A joint scenario should make clear whether it changes the cost within each state, the strategy’s state mix, quantities or several of these at once.
Return to the quiet and active example. Keep quiet cost at 0.8 pips and active cost at 2.4 pips. With 20% of trades active, the average is 1.12 pips; with 80% active, it is 2.08 pips. Now impose an active-state cost of 3.2 pips while leaving quiet cost unchanged. The corresponding averages become 1.28 and 2.72 pips. These four cells isolate the interaction between where the strategy acts and the cost of acting there.
The grid is not a forecast of future market states. It is a transparent set of hypothetical assumptions. Its value lies in showing which combination drives the conclusion. If a strategy appears acceptable only when activity is concentrated in the cheap state, the next investigation should examine that concentration rather than merely testing another global multiplier.
Do not change activity without explaining why it changes. A price-path stress may naturally alter the strategy’s signals, while a diagnostic grid may impose a different mix by design. Those are different experiments. If signals are recalculated on a stressed path, preserve the causal timing of the indicators and replay the relevant constraints. If the mix is imposed, label it as a hypothetical reweighting rather than an observed response of the robot.
Keep the number of scenarios manageable and justified. An enormous grid can become another optimization surface if the researcher selects only the cells that support a preferred conclusion. Choose a few interpretable stresses, retain unfavorable cells and record why the ranges were considered. Where evidence is weak, a range of conditional results is more honest than a single precise “realistic cost” estimate.
A quote archive is evidence about quotes, not every possible fill
Historical bid and ask data can substantially improve a midpoint-only cost model. They reveal how quoted spreads vary and allow the researcher to align quotes with signals under a stated timestamp convention. But they do not automatically reveal available depth, latency, partial execution or the price that a particular quantity would have obtained. The distinction should remain visible in the report.
The BIS report on FX execution algorithms discusses how automated execution changes the allocation of execution risk and the demands on users’ monitoring. That institutional context supports taking the execution mechanism seriously; it does not supply a cost model for a small research robot. BIS: FX execution algorithms and market functioning. The relevant implementation still needs its own data and assumptions.
If the dataset contains one quote per minute, specify how a signal within the minute is matched. Using the most favorable quote observed later in the interval would introduce hindsight. Using the last quote available before the signal may be causally appropriate but could be stale. Neither choice should be hidden inside a library default. Record quote age and the policy for intervals without a sufficiently current observation.
Unknown execution detail should remain unknown in the evidence record. It can be represented by explicit sensitivity ranges or additional data collection, but not by an invented fill described as observed. If a demo environment later produces execution logs, those logs can be compared with the model under their own conditions. They still do not guarantee identical behavior in every other environment.
A useful hierarchy is to state what is directly recorded, what is reconstructed from recorded fields and what is imposed as a scenario. For example, a quoted spread may be observed, a midpoint-relative cost reconstructed and a latency penalty hypothetical. Keeping those roles separate allows the model to improve as evidence arrives without rewriting the provenance of earlier numbers.
Estimate conditional costs without treating every row as independent
Signals often arrive in bursts. Twenty expensive executions during one event may provide much less information about a general state-dependent cost relationship than twenty executions spread across unrelated conditions. A large row count can therefore coexist with limited coverage. Inspect the distribution of events across days, sessions and shared episodes before interpreting a narrow standard error.
Separate the estimation sample from the evaluation of the resulting cost model. If state boundaries and cost estimates are repeatedly adjusted to fit the same outcomes, the final model can describe that archive well without demonstrating predictive relevance. A later period or another clearly separated evaluation can ask whether the model’s conditional estimates remain useful. The point is not to freeze learning forever, but to record when learning occurred.
Sparse states require restraint. A cell containing two unusual events should not receive the same apparent precision as a cell with extensive representative observations. Report counts and total quantity, consider simpler pooling where justified and show sensitivity to reasonable alternatives. A more complex model is not automatically more faithful when the data cannot support its detail.
The rare expensive state may matter more economically than statistically convenient averages. That does not justify inventing its probability. It justifies separating a descriptive estimate from a stress scenario and explaining the uncertainty. The researcher can then decide which additional observations would reduce the most consequential gap rather than collecting more data from already well-covered quiet periods.
Beware survivorship in providers and environments too. A historical cost archive may reflect a particular account convention, feed or implementation version. Combining records across changes without labels can create a synthetic average that no actual setup experienced. Preserve version boundaries and compare like with like before deciding whether a shift is market-driven or an artifact of the measurement process.
Changing a filter is not the same as improving the cost model
Once a researcher discovers expensive signal states, the natural temptation is to prohibit those states. That is a strategy intervention. It may improve or worsen net results depending on the gross opportunities removed, later capacity and the policy’s response. Updating the cost estimate while holding the strategy fixed answers a different question from changing the strategy because the new estimate is unfavorable.
Run the diagnostic in a sequence that preserves attribution. First reconcile the original policy under the old and revised cost assumptions, using the same candidate and accounting basis where feasible. Then evaluate any proposed filter change as a separate version. Report both the cost-model revision and the policy revision rather than presenting the final curve as though only one harmless input had been corrected.
A filter based on current spread can also create a waiting policy. If the system delays an entry until the spread narrows, the later price and signal validity may differ. Treating the delayed trade as if it occurred at the original favorable reference price overstates the effect of patience. Cheaper execution and unchanged opportunity are not automatically compatible. The opportunity may disappear, reverse or occupy capacity differently while the policy waits.
The same applies to quantity changes. Reducing size in expensive states can lower total cost while also reducing exposure to their gross outcomes. A report should distinguish improvements in cost per unit from simple reductions in traded quantity. A smaller total bill is not proof of a more efficient execution mechanism if the strategy simply did less business.
These distinctions are useful commercially as well as scientifically. A source-code package is valuable because the buyer can inspect and adapt the rules, but adaptation produces a new policy whose behavior must be evaluated. A cost study should make that process clearer, rather than suggesting that one discovered filter creates a universally superior version of every supplied system.
Produce a cost report that someone else can reconcile
The report should identify the data source, timestamp convention, quote age rule, account currency, quantity convention and cost components. Show the difference between time-weighted, opportunity-weighted, execution-weighted and quantity-weighted summaries when they answer relevant questions. Do not overload the page with every possible metric; include the ones needed to explain the main conclusion and its most important sensitivities.
For each conditional group, preserve the number of opportunities, number of executions, total quantity and the available cost observations. A low average among a handful of surviving fills should not hide a high rate of unavailable execution. Include missingness and exclusions in the reconciliation so that the reader can tell whether a result reflects economics or a narrowed sample.
Use a small set of invariance checks. Splitting one execution into two equal records should not change total monetary cost. Reordering fixed additive costs should not change their sum. A zero-cost diagnostic should reconcile with the gross reference-price result. These checks do not prove that the cost model is realistic, but they can expose implementation errors before the researcher interprets them as market behavior.
Every net result should have an inspectable route back to its gross result. If the totals do not reconcile, stop the economic interpretation and identify the accounting discrepancy. If they do reconcile, the remaining question is whether the assumptions and data represent the intended execution conditions. Arithmetic validity and economic relevance are both necessary, and they require different kinds of evidence.
An AI assistant can help build these reconciliations, flag inconsistent units and generate small artificial cases with known answers. Ask it to explain why each average uses its denominator and to preserve all rejected or missing opportunities. Avoid asking it to choose whichever cost model makes the archived strategy look attractive. That would turn a measurement exercise into another selection step over the same outcomes.
Begin with the moments that matter to the strategy
Choose one system and inspect a limited set of its candidate timestamps. Place the available quotes beside them, identify the price convention and calculate a transparent cost proxy. Compare that activity-weighted estimate with the time-weighted average of the same archive. If they differ, investigate which states and quantities explain the gap before adding complexity to the model.
Then define one joint stress that changes a meaningful condition rather than every number indiscriminately. It might increase costs in a documented class of active intervals or test how a different signal mix changes the average. State which inputs are observed and which are hypothetical. Preserve the resulting ledger so the next researcher can reproduce the calculation and challenge the assumptions.
The TradeAndRoll free demo includes ten Forex systems, rules, source code, market CSVs and research prompts. The files provide material for examining signals and cost assumptions; their availability does not establish that every required execution field is present or that a historical cost proxy will match a particular provider. Begin by checking what the supplied data actually measure and identify any additional evidence the chosen question requires.
Your signals help determine the costs you encounter. A market average can be accurate and still be the wrong input for a strategy. Align costs with opportunities, quantities and state, keep timing distinct from total amounts and show the arithmetic that connects assumptions to net results. That turns a generic fee adjustment into a research question with a clear economic purpose.



