Slippage and Commission: The Hidden Costs Killing Trading Bot Profits
Back to Blog
EducationMay 18, 20269 min read

Slippage and Commission: The Hidden Costs Killing Trading Bot Profits

PF

PineForge Team

Automated Trading Platform

A trader builds a strategy that backtests at +35% annual return over five years of historical data. They deploy it live. Six months later, the actual return is +8% — and they can't figure out where the 27% went. The strategy logic is identical. The trades are entering at the right times. The bot is doing what it was supposed to do. So why the gap?

The answer is execution cost — slippage, spread, and commission. Standard backtests assume idealised execution that real trading doesn't deliver. The strategy isn't broken; the backtest was incomplete. This guide breaks down each cost component, shows how to model them in your backtest, and identifies the strategy types most vulnerable to these hidden frictions.

A trading dashboard showing the gap between an idealised backtest line and a realistic live trading line, with execution cost annotations highlighted in amber on a dark fintech background
A trading dashboard showing the gap between an idealised backtest line and a realistic live trading line, with execution cost annotations highlighted in amber on a dark fintech background

What's the difference between slippage and spread?

These terms get used interchangeably but mean different things.

Spread is the gap between the bid (sell price) and ask (buy price) at the moment of trade. It's a fixed cost per round-trip trade — buy at the ask, sell at the bid, you've paid the spread. On EURUSD with a 1-pip spread, every round-trip trade costs 1 pip regardless of how the trade performs.

Slippage is the difference between the price your bot expected and the price the broker actually filled at. Order arrives expecting to buy at 1.0850, gets filled at 1.0852 — 2 pips of slippage. Slippage is usually larger than spread on fast-moving markets and zero or negative in calm markets.

Commission is a per-trade fee charged by the broker, typically expressed as $X per round-trip lot. Often present on ECN brokers and absent on market-maker brokers (who embed their cost in wider spreads instead).

All three are costs. All three need to be modeled. Skipping any of them inflates backtest results.

Why backtests overestimate returns

Standard backtest engines fill orders at the closing price of the signal bar (or the open of the next bar). They assume:

  • Zero spread — the buy and sell happen at the same price
  • Zero slippage — the fill matches the expected price exactly
  • Zero commission — no per-trade fee
  • Infinite liquidity — your order doesn't move the market
  • In live trading, none of these hold. The realistic costs depend on instrument, broker, and strategy frequency:

    A round-trip cost of 1.5–3 pips on a major pair is realistic. On gold, $1–$2 per ounce. On crypto, 10–50 basis points. These are the costs your backtest needs to include.

    How much do execution costs actually matter?

    Depends entirely on strategy frequency and per-trade edge.

    A position-trading strategy taking 12 trades a year with 200-pip average wins and 100-pip average losses sees roughly 2% of profit eaten by execution costs. Negligible.

    A 1H bot taking 80 trades a year with 25-pip average wins and 15-pip average losses sees execution costs consume roughly 25% of gross profit. Significant.

    A 5M scalping bot taking 800 trades a year with 4-pip average wins and 3-pip average losses sees execution costs *exceed* gross profit. The strategy is net unprofitable once realistic costs are included — even if the backtest looked great.

    This is why high-frequency retail strategies almost always disappoint live. The backtest didn't include the costs that dominate at that frequency.

    How do you model slippage in a backtest?

    Three approaches, in increasing order of realism:

    Fixed slippage in pips/cents

    Simplest. Add N pips of slippage to every trade. For EURUSD, 1 pip on entry and 1 pip on exit. For gold, 30 cents each way.

    //@version=6

    strategy("With Slippage",

    overlay=true,

    slippage=2) // 2 ticks per side

    This is the minimum acceptable. It significantly improves backtest realism with zero analytical complexity.

    Time-of-day variable slippage

    Slippage isn't constant. It's higher during news events, illiquid hours, and session opens. A more realistic model adjusts slippage by time-of-day.

    PineForge's backtest engine supports this via the cost-model configuration: specify a base slippage and a multiplier for high-volatility windows. The backtest applies the appropriate multiplier based on the trade's timestamp.

    Volatility-scaled slippage

    The most realistic approach: slippage scales with ATR. When ATR is at its 90th percentile, slippage is roughly 2x normal. When ATR is at its 20th percentile, slippage is roughly half normal.

    This requires custom implementation but produces the most accurate cost model. For strategies you're seriously considering deploying live, the extra modeling work pays for itself many times over by preventing strategy deployment based on inflated backtests.

    What about commission costs?

    Commissions are simpler — they're a fixed dollar amount per round-trip lot. The Pine Script v6 syntax:

    //@version=6

    strategy("With Commission",

    overlay=true,

    commission_type=strategy.commission.cash_per_order,

    commission_value=3.50) // $3.50 per round-trip

    For percentage-based commissions (typical in crypto):

    strategy("With Percent Commission",

    commission_type=strategy.commission.percent,

    commission_value=0.05) // 0.05% per trade

    Crypto exchanges typically charge 0.05–0.1% per trade. Forex ECN brokers charge $3–$5 per round-trip standard lot. Market-maker forex brokers charge zero commission but compensate with wider spreads.

    Either way, the cost is real. Model it explicitly.

    What strategies are most vulnerable to execution costs?

    The simple rule: vulnerability scales with per-trade edge divided by execution cost.

    Highly vulnerable:

  • Scalping (sub-15-minute holds, sub-10-pip targets)
  • Grid strategies (many simultaneous orders, frequent re-entries)
  • Tight-stop breakouts (entries close to stops)
  • Moderately vulnerable:

  • 1H momentum bots
  • Mean-reversion strategies on majors
  • Multi-timeframe systems with frequent re-entries
  • Less vulnerable:

  • Daily and 4H trend-following
  • Swing strategies with multi-day holds
  • Position-trading systems with weekly+ holds
  • If your strategy backtests well but is in the "highly vulnerable" category, expect 30–60% of backtested return to disappear in live trading once realistic costs are included.

    How do I calculate the break-even cost for my strategy?

    Run the backtest twice — once with zero costs (the idealised baseline) and once with realistic costs. The difference is the cost burden.

    Then ask: if costs were 50% higher than the realistic estimate, would the strategy still be profitable? If yes, the strategy has cost resilience. If no, the strategy is on the edge of viability and any broker change (wider spreads, higher commissions) could push it negative.

    The break-even calculation:

  • Total net profit at zero cost: $X
  • Total commission paid in trades: $C
  • Total slippage paid (sum of slip per trade × pip value × lots): $S
  • Effective cost per trade: ($C + $S) / number_of_trades = $E
  • Average win per trade: $W
  • Average loss per trade: $L
  • If $W is less than 2 × $E, the strategy has minimal margin and is vulnerable to any cost increase. If $W is more than 5 × $E, the strategy can absorb significant cost variation.

    What about broker selection?

    Broker choice materially affects realised costs. Three factors matter:

  • Spread quality. ECN brokers typically offer 0.1–0.3 pip raw spreads on EURUSD + commission. Market-maker brokers offer 1–2 pip spreads with zero commission. For high-frequency strategies, ECN is usually cheaper. For low-frequency strategies, market-maker can be competitive.
  • Slippage behavior. Some brokers have "no slippage" guarantees that quietly reject orders during fast markets. Other brokers honor stops at any price — including very bad ones. Test with small live trades before committing capital.
  • Order types supported. Stop-limit orders limit slippage but can leave you unfilled. Market orders guarantee fill but accept any price. Strategy logic should match the order types your broker supports reliably.
  • PineForge's accounts setup guide covers MT5 broker selection for automated trading. Different brokers behave very differently under stress.

    Should I include slippage in my backtest from day one?

    Yes — always. The most expensive mistake in retail algo trading is building a strategy in a zero-cost simulator, deploying it live, and discovering the cost burden in real losses. Start with realistic costs in the backtest. If the strategy is profitable with costs included, it might work live. If not, you've saved yourself the deployment cost.

    Conclusion

    Execution costs aren't a footnote. They're the single largest source of backtest-to-live divergence in retail algo trading. A strategy that ignores them in the backtest will overestimate returns by 30–70% depending on frequency.

    Three rules:

  • Always backtest with realistic slippage, spread, and commission. Use PineForge's backtest engine, which supports realistic cost modeling natively.
  • Test break-even sensitivity — if 50% higher costs would kill the strategy, the strategy is fragile.
  • Match strategy frequency to your edge. Sub-1H strategies need sub-1H-grade edge; daily strategies have more cost margin.
  • Build with costs in mind. Deploy strategies that survive realistic friction. The bot that prints money in a clean simulator and loses in live trading isn't a strategy problem — it's a cost-modeling problem.

    pinescript
    //@version=6
    strategy("With Slippage",
         overlay=true,
         slippage=2)  // 2 ticks per side
    pinescript
    //@version=6
    strategy("With Commission",
         overlay=true,
         commission_type=strategy.commission.cash_per_order,
         commission_value=3.50)  // $3.50 per round-trip
    pinescript
    strategy("With Percent Commission",
         commission_type=strategy.commission.percent,
         commission_value=0.05)  // 0.05% per trade
    InstrumentTypical spreadTypical slippagePer-trade commission
    EURUSD0.5–1 pip0.3–1 pip$3.50/lot (ECN)
    GBPUSD1–2 pips0.5–1.5 pips$3.50/lot (ECN)
    XAUUSD20–40 cents10–30 cents$5/lot (ECN)
    GBPJPY2–4 pips1–3 pips$4/lot (ECN)
    BTCUSD$5–$50$5–$1000.05–0.1%

    Start Trading Smarter

    Build, backtest, and deploy your strategies with PineForge. No coding experience required.