Worked example of backtesting practice (with explicit assumptions)

Learn backtesting practice with a worked example and assumptions.

Direct answer: what a worked example of backtesting practice is

A worked example of backtesting practice shows, step by step, how you would apply a clearly defined rule to historical data to estimate what would have happened. “Backtesting” here means you simulate decisions using past observations, without assuming future results will match history. “Practice” means you record every assumption so another person can reproduce the same calculations and check where the result comes from.

Mechanism and definition: what you do in a backtest

Backtesting practice typically has five inputs:

  1. A decision rule: exactly when you would enter/exit (or how you would compute a prediction/score).
  2. A dataset: historical time series with consistent timestamps.
  3. A trading model: how orders fill (e.g., using the next bar open) and how you handle spreads.
  4. A cost model: commissions, fees, and spread assumptions.
  5. A metric: what you measure (e.g., cumulative return, drawdown, hit rate, or average return per trade).

Stable mechanics: the workflow (define rule → choose data window → simulate fills → compute metrics → document) stays the same. Variable conditions: the market regime, data quality, execution details, and costs can change, and they can dominate outcomes.

Worked example (numerical scenario) with explicit assumptions

Assume the goal is to evaluate a simple rule for educational purposes. This is not a recommendation, and it uses synthetic-like simplifications to keep assumptions explicit.

Rule (the “if-then”)

For each day, you hold a position for exactly 1 day. The position is either “long” (take exposure) or “flat” (no exposure). The decision rule is:

  • If the previous day’s close is higher than two days ago’s close, take long exposure for the next day.
  • Otherwise, be flat for the next day.

Dataset (historical observations)

Use six consecutive daily observations (Day 0 to Day 5). Assume the closes below are the “known” historical prices for backtesting:

  • Day 0 close: 100
  • Day 1 close: 102
  • Day 2 close: 101
  • Day 3 close: 103
  • Day 4 close: 104
  • Day 5 close: 102

We will compute decisions for Days 2–5 because the rule needs Day t-2.

Execution and cost assumptions

These assumptions determine the simulated return.

  • Entry price: next day’s open equals that day’s close (simplification). This removes intra-day uncertainty.
  • Exit price: the following day’s close equals the next day’s close (since the holding period is 1 day).
  • Spread and commission: total trading cost is a fixed 0.1% of notional on every day you are long. If flat, cost is 0%.
  • No leverage constraints, no margin interest, and no slippage beyond the cost model.

Metric definition

Compute a “net daily return” on notional:

  • If long on day t: net return = (Close(t) / Close(t-1)) − 1 − 0.001
  • If flat: net return = 0

Step-by-step simulation

Decisions:

  • For Day 2 decision: compare Day 1 close (102) to Day 0 close (100). 102 > 100 → go long on Day 2.
  • For Day 3 decision: compare Day 2 close (101) to Day 1 close (102). 101 > 102 is false → flat on Day 3.
  • For Day 4 decision: compare Day 3 close (103) to Day 2 close (101). 103 > 101 → long on Day 4.
  • For Day 5 decision: compare Day 4 close (104) to Day 3 close (103). 104 > 103 → long on Day 5.

Compute net returns:

  • Day 2 (long): Close(2)/Close(1) − 1 − 0.001 = 101/102 − 1 − 0.001 ≈ −0.0098039 − 0.001 = −0.0108039 (≈ −1.08%)
  • Day 3 (flat): net = 0
  • Day 4 (long): 104/101 − 1 − 0.001 = 0.0297029 − 0.001 ≈ 0.0287029 (≈ +2.87%)
  • Day 5 (long): 102/104 − 1 − 0.001 = −0.0192308 − 0.001 ≈ −0.0202308 (≈ −2.02%)

Cumulative simple sum (since this example uses small numbers and is illustrative): total net return ≈ −1.08% + 0% + 2.87% − 2.02% ≈ −0.23% over the evaluated period.

What the worked example teaches: the outcome is produced mechanically from your rule, your data, and your explicit execution/cost assumptions.

Limitations and failure modes (what can go wrong)

  1. Overfitting: if the rule is tuned to past data too closely (many knobs, many tests), it may look good historically but fail elsewhere. 2) Execution realism: assuming perfect fills or simplified pricing can exaggerate results.
Trading foreign exchange and CFDs involves substantial risk. Information on FoxiForex is educational and is not personal financial advice. Sponsored placements are labelled clearly.