▲ Work in progress. This site is built and researched in the open: pages, numbers and findings may change or be wrong, and the record has gaps. Not advice. More

The Lab

Ideas traders use, put to the record

← the Lab · models explained · write-up

#60 How our backtester works, step by step

Past prices; no real orders were placed. Every figure is a share of the money, a price, or a count.
Last checked: 20 October 2026.

Where the idea comes from

The question

What does our backtester do, step by step? And how far can its answers be trusted?

What it is

The loop, one candle at a time (grid bots)

1. Plan at the open. At each candle's opening price, the bot's own planner says which orders it would have resting on the exchange: buys under the price, sells over what it holds.

2. Keep only what the live bot would rest. The live bot keeps only orders near the price resting (within 5%, or two rung gaps when that is wider). The rehearsal keeps the same.

3. Fill only what the price trades through. A buy at 99.92 fills only if the candle's low goes under 99.92. Just touching it is not enough, because at that price there could be a queue of other orders ahead of ours.

4. A lot can't be sold in the candle it was bought in. The planner only looks at each candle's open, so a lot bought during a candle gets its sell order at the next one. This is the cautious side: live, it could have sold sooner.

5. Pay the costs. The exchange's fee on every fill (0.02% for a resting order on Bybit). The real funding at each 8-hour payment, on what the bot holds, read from the exchange's history.

6. Stop where the bot would. If the bot has a stop-loss or a loss limit, the rehearsal checks it on every candle, at the bot's own level:

7. Keep score. Profit from finished buy-and-sell trips, the value of what is still held, and the deepest drop. The first moment the bot, on its own money, would have reached the exchange's liquidation line. And, given the account's latest state, how close the whole account would have come to it.

A worked example

A long grid from 96 to 104, five rungs, 1,000 USDT, no leverage, with a stop at 95. The rungs sit 2% apart: 96, 97.94, 99.92, 101.94 and 104. Each buy is 200 USDT, and each sells one rung up. Seven made-up hourly candles, run through the engine's own code:

candleopenhighlowclosewhat happenedtripsprofit, after fees
1101101.599.5100.2low passes 99.92: buy 2.0016 coins0−0.04
2100.2100.497.998.1low passes 97.94: buy; the high (100.4) passes this lot's sell (99.92), but that sell is only placed next candle0−0.08
398.1100.397.5100.1sell the 97.94 lot at 99.921+1.92
4100.1102.4100102.2sell the 99.92 lot at 101.94: nothing held2+7.92
5102.2102.3101.94102low only touches 101.94: no fill2+7.92
6102102.1101.5101.6low passes 101.94: buy2+7.88
7101.6101.794.595.2low passes 99.92 and 97.94: buy, buy; then 95: the stop sells everything2−21.98

Profit in USDT.

What it assumes, plainly

assumptionwhich way it leans
fills need the price to trade through, not touchcautious
a lot can't sell in the candle it was bought incautious
on long candles, every rung a fast move passed fillshopeful (live, a fast move can skip rungs)
resting orders fill at exactly their pricefair: a resting order can't slip
a small, fixed gap between buying and selling priceshopeful in thin markets
real funding for Bybit futures; otherwise "not modelled", saidfair
one bot at a timecan't see bots sharing one account
a stop is judged on the mark price the bot watches, from Bybit's mark-price candlesfair, on Bybit
on Hyperliquid, which publishes no mark-price candles, a stop is judged on the trade priceshopeful in a crash, when the two can be far apart (see below)
a stop that fires sells at its level, with no slippagehopeful (see below)
DCA bots: when one candle hits both the stop and the target, the stop comes firstcautious

Measured 1: how much the candle size matters

The same Bitcoin grid, replayed on 1-minute candles, and on bigger candles built from the same minutes. The setup: 12 months (October 2025 to September 2026); each month a fresh long grid from 15% under the start to the same distance over, 20 rungs, 10,000 USDT, no leverage, with Bybit's real order steps, fees and funding.

candletrips a monthof the 1-minute tripsnet a monthgap to 1-minute: averagegap: worst month
1 minute23.4100%−0.56%
5 minutes22.496%−0.58%−0.02%0.16%
15 minutes22.095%−0.61%−0.06%0.50%
1 hour20.789%−0.71%−0.15%0.87%
4 hours18.280%−0.87%−0.31%1.18%

Net: a share of the money, after fees and funding, with what is held at each month's end sold. It was a falling year for Bitcoin, so a long grid lost.

The same grid, the same months, replayed on bigger candles
↑ round trips a month
051015201 minround trips, 1 min: 23.425 minround trips, 5 min: 22.4215 minround trips, 15 min: 221 hourround trips, 1 hour: 20.674 hoursround trips, 4 hours: 18.25
candle size →
— round trips

The bigger the candle, the fewer round trips the replay could see, because a lot cannot sell in the candle it was bought in.

Measured 2: slippage

A resting order can't slip: it fills at its own price or not at all. A market order can: it takes whatever is offered, from the best price down. Our bots send market orders to stop or close. The rehearsal fills those with no slippage.

What a market order would have cost beyond the middle price, from Bybit's public order book: 10 readings, 30 seconds apart, on 20 October 2026 at about 10:41 UTC.

coin1,000 USDT10,000100,0001,000,000
Bitcoin0.0001%0.0001%0.0001% (worst 0.005%)0.006% (worst 0.013%)
Ether0.0002%0.0002% (worst 0.009%)0.001% (worst 0.016%)0.014% (worst 0.024%)
Solana0.005%0.005% (worst 0.010%)0.009% (worst 0.016%)0.041% (worst 0.052%)

The middle of 10 readings, the worst in brackets where it differs. The market-order fee itself is 0.055%.

How we use it

What it means

Limits

Credits

← Hidden order: the BDS testSkill or luck →

Educational research from public market data; any trading discussed is paper, never real. Nothing here is advice. The full notice.