Skip to content

AmiBroker Backtesting

A backtest is not a measurement. It is a simulation, and every simulation is a stack of assumptions with a number printed on top. The number is the part everyone reads. The stack is the part that decides whether the number means anything.

Part 27 got you as far as a rule set that two people would implement identically. This part is about the machine that turns that rule set into a simulated account: what AmiBroker does with your Buy array, which price it fills you at, how many shares it buys, what it charges you, when it takes you out, and what changes when ninety symbols are competing for one pot of money instead of one symbol having the pot to itself.

What sits between a rule and a reported return

  1. Your rulesBuy, Sell, Short, Cover — one value per bar, no timing information
  2. TimingSetTradeDelays() decides which bar the signal is acted on
  3. Fill priceBuyPrice and friends decide what you paid, clamped to the bar range
  4. SizeSetPositionSize() decides how much of the account is at stake
  5. CostsCommission, slippage, spread — subtracted from every leg
  6. ExitsRule exits and ApplyStop() compete for the same trade
  7. The accountOne cash balance, a position limit, and a rank that refuses the surplus
  8. The reportWhat you were going to read first

Part 29 reads AmiBroker’s backtest report in AmiBroker’s own vocabulary. It would be an easier part to write first, and a worse one to learn first, because almost every serious misreading of a backtest report is really a misunderstanding of something in the stack above. A spectacular Risk Adjusted Return % usually means the system was barely in the market. An implausibly smooth equity curve usually means the stops were assumed to fill at a price nobody had to offer. A system that appears to ignore most of its own entries is usually running into the documented behaviour of the default backtest mode.

None of those are report problems. They are simulator problems that only become visible in the report.

An end-of-day database with a few years of daily bars for a watch list of liquid instruments — twenty to fifty names is plenty. Nothing here needs a real-time feed, a data subscription or the Professional edition; every formula in the part runs on free end-of-day history in the Standard edition. The one place edition matters is throughput: the Standard edition runs two threads per Analysis window against the Professional edition’s thirty-two, so a large optimisation takes longer, not different.

You also need to have read Part 27, or to be willing to accept a rule set you did not write. Several formulas here reuse the trend system from that part’s project so that the subject of the page stays on the simulator rather than drifting into strategy design.

Every formula in this part opens with a block of assumptions: fill price, delays, commissions, slippage, liquidity, financing, data. That block is not decoration and it is not there to satisfy a style rule. It exists because a backtest result is only interpretable next to the assumptions that produced it, and because those assumptions are exactly the things you will forget three weeks later when someone asks you what the number meant.

You will be able to write a portfolio backtest whose every material assumption is visible in the formula rather than buried in a settings dialog; to explain why the same rules produce a different answer at portfolio level than symbol by symbol; to say precisely which stop configurations award your simulation a fill that no order book had to provide; and to take the single most repeated claim in technical analysis, test it properly, and describe the result without deciding in advance what you wanted it to be.

Part28 of 36Level4 — Trading System ResearcherPages8Estimated time4.8 hours

0 / 8 lessons in this part completed

Sources for this lesson

2 verified · checked 2026-08-31

  1. 01AmiBroker User's Guide — Back-testing your trading ideasamibroker.com/guide/h_backtest.html2026-08-31
  2. 02AmiBroker User's Guide — Portfolio-level backtestingamibroker.com/guide/h_portfolio.html2026-08-31

Every technical claim on this page was checked against the official AmiBroker documentation on the date shown. Where the course disagrees with folklore, the source is how you can tell which one to trust.