Slippage in a Trading Bot: Why the Backtest Flatters Your Entry Price
An automated entry involves two prices that are rarely identical: the price at which the signal appears, and the price at which the order actually fills. The gap between them is slippage. It tends to weigh more heavily on automated strategies than on manual trading - not because the technology is slower, but because a bot triggers at exactly the moments when plenty of others are reacting too.
What a backtest quietly assumes about execution
A backtest usually fills the order at the signal price or the candle close, in full size and without a spread. Live, that same order meets an order book that has moved on in the meantime, and it gets whatever that book offers at that moment. The difference isn't a rounding error, it's a cost that lands on every single trade - and always in the same direction.
Market order: certain fill, uncertain price
A market order takes whatever is resting in the book. That makes the fill practically certain and the price anything but. In thin books, or right after a trigger that many participants react to at once, the fill can land several ticks away from the expected price. The upside is still substantial: the strategy actually gets into the position it was designed for.
Limit order: certain price, uncertain fill
A limit order fills at your price or better - or not at all. The real catch isn't that trades get missed, it's which ones: you tend to get filled when price comes back to you, and you miss out when the market runs away immediately. The fast moves are systematically absent while the hesitant ones land in the results in full. So a limit order doesn't simply reduce cost, it changes the composition of the trades - and a backtest that treats every limit order as filled flatters the result even more than one using market orders.
Not sure which order type fits your strategy?
Describe the logic and the instrument you trade - the feasibility check and quote are free and non-binding.
Request a projectThe special case of stop orders
For protective stops the trade-off reverses. A stop-market order fills at the next available price once triggered and can fill noticeably worse in a fast move. A stop-limit order avoids exactly that - at the cost of possibly not filling at all if the market jumps past the limit. The position then stays open even though the stop has triggered. For protection that's usually the wrong direction: what counts is being out, not the exact tick you got out at.
When execution cost decides the strategy
- The ratio of average profit per trade to execution cost - with targets of a few ticks, a single tick of slippage can consume the entire expectancy
- Trade frequency, since per-trade cost scales linearly with the number of trades
- Instrument and time of day, because execution quality isn't constant - it depends on liquidity and trading hours
- Order size relative to market depth: an order that clears several price levels gets a blended price rather than the best one
What the bot should log about it
- Expected price at signal time and actual fill price, stored per order
- Analysis by instrument, time of day and order type instead of a single average figure
- Partial fills recorded separately, since a blended price otherwise looks like one clean execution
- Unfilled limit orders counted too - without them, exactly the part that skews the statistics is missing
For why a backtest can be too generous independently of execution, see the article on overfitting in trading strategies.
Frequently Asked Questions
Can slippage be accounted for in a backtest?
A flat cost deduction per trade is possible and better than no assumption at all. What it doesn't capture is that execution cost is highest precisely when it hurts most - in fast moves. The number only becomes reliable once it's checked against real fills from live operation.
Isn't a limit order simply the better choice?
No. It lowers the cost of each executed trade, but it preferentially removes the fast moves from your results. Whether that works depends on whether the strategy relies on participating in a move that starts immediately.
Does a faster server help against slippage?
It reduces the portion caused by latency, not the portion caused by liquidity. If there simply isn't enough resting in the book, a faster connection changes nothing.
How much slippage is normal?
There is no universal figure - it depends on the instrument, order size, trading hours and order type. Only your own logging produces a usable number, which is exactly why it belongs in the bot from the start.
Execution cost can't be programmed away, but it can be measured. A strategy that still looks viable after realistic execution is deducted stands on far firmer ground than one whose edge lives entirely inside the backtest's assumptions.
Have an idea for ATAS?
Tell us about your project - you'll get a free, non-binding quote within 24-48 hours.
Request a Free Quote