Fees and Slippage: The Silent Strategy Killers
Part of the guide: Pine Script backtesting
In short
Fees, spread and slippage are small per trade but paid on every trade. At 0.1% per order, 200 round trips cost about 40 percentage points as a simple sum, so a strategy gaining 0.2% per trade before costs ends at zero; compounded, fees alone take roughly 33% of the account of a strategy that breaks even before costs.
Most backtests run in a world where trading is free. TradingView strategies, for example, assume zero commission and zero slippage unless you change the settings (TradingView docs). Real exchanges usually charge a fee on every filled order, and you rarely get exactly the price you planned.
Each cost looks tiny, often a tenth of a percent or less, but you pay it on every trade. This guide, part of our series on backtesting a strategy properly, shows how fast costs add up and how to model them in Pine Script.
The three costs of every trade
- Trading fee (commission): what the exchange charges for each filled order, usually a percentage of the order's value. You pay it when you buy and again when you sell. One buy plus the matching sell is called a round trip.
- Spread: the gap between the highest price buyers offer (the bid) and the lowest price sellers accept (the ask) (Binance Academy). Buy at the ask, sell at the bid right away, and you lose the spread although the price did not move.
- Slippage: the difference between the price you expected and the price you got. It is common in fast markets and when few orders sit near the current price, which traders call low liquidity (Binance Academy).
Maker and taker fees on crypto spot exchanges
Crypto exchanges usually charge two rates. A maker order waits in the order book, the list of open buy and sell orders, and adds liquidity. A taker order fills immediately against orders already there. A market order (buy or sell now at the best available price) is therefore a taker. A limit order (buy or sell only at your price or better) usually waits as a maker, but becomes a taker if it matches an existing order at once (Binance Academy).
| Exchange | Account level | Maker fee | Taker fee |
|---|---|---|---|
| Binance | Regular user | 0.100% | 0.100% |
| Binance, fees paid in BNB | Regular user | 0.075% | 0.075% |
| Bybit | VIP 0 | 0.100% | 0.100% |
| Kraken Pro | Tier 1 (lowest volume) | 0.40% | 0.80% |
Sources: Binance fee schedule, Bybit fee structure, Kraken fee schedule. So a small account pays 0.075% to 0.8% per order, a more than tenfold range.
Spread and slippage
Spread and slippage are not on any price list. Liquid pairs such as BTC/USDT usually have small spreads, less liquid coins wider ones. Slippage usually grows with order size and market speed: a market order takes the best price first, and if the volume there runs out, the rest fills at worse prices (Binance Academy).
Breakout strategies (buying when price breaks above a recent high) often trade in fast markets, when slippage tends to be largest. And a candle chart stores one price series (open, high, low, close), not separate bid and ask prices, so a backtest does not see the spread unless you add it.
Worked example: 200 trades at 0.2% per round trip
Imagine a strategy that makes 200 trades in your test, each a buy followed by a sell, with a 0.1% fee on every buy and every sell: about 0.2% per round trip. To keep the arithmetic simple, we add returns instead of compounding them and assume every trade gains the same before costs.
The costs: 200 × 0.2% = 40 percentage points. A percentage point is the plain difference between two percentages: going from +50% to +10% is a drop of 40 points. The strategy's edge, its average gain per trade before costs, has to fill that hole before you earn anything.
| Average gain per trade before costs | 200 trades, no costs | After fees (0.2% per round trip) | After fees and slippage (0.3% per round trip) |
|---|---|---|---|
| 0.1% | +20% | -20% | -40% |
| 0.2% | +40% | 0% | -20% |
| 0.3% | +60% | +20% | 0% |
| 0.5% | +100% | +60% | +40% |
| 1.0% | +200% | +160% | +140% |
Take the second row. A gain of 0.2% per trade shows +40% without costs and exactly nothing after fees (40 − 40 = 0). With 0.05% slippage per side, a round trip costs 0.3%, the costs grow to 200 × 0.3% = 60 points, and the total falls to 40 − 60 = −20. At 1% per trade, the same costs barely matter. What counts is the cost compared with the average gain per trade.
Compounding (reinvesting the whole account every time) changes the numbers a little, not the picture. Each 0.1% fee leaves 99.9% of your money, so a round trip leaves 0.999 × 0.999 = 0.998001. After 200 round trips: 0.998001 to the power of 200, about 0.670. A strategy that breaks even before costs loses roughly 33% of the account to fees alone.
Why frequent trading eats small edges
Trading more often usually means smaller gains per trade: on a 1h chart, price has less time to travel between entry and exit than on a daily chart. The fee per trade stays the same. Compare two made-up strategies over one year:
| Per year | Strategy A | Strategy B |
|---|---|---|
| Trades | 20 | 400 |
| Average gain per trade before costs | 3% | 0.25% |
| Total before costs | +60 | +100 |
| Costs at 0.2% per round trip | -4 | -80 |
| Total after costs | +56 | +20 |
| Costs at 0.3% per round trip | -6 | -120 |
| Total after higher costs | +54 | -20 |
Before costs, B looks better. After fees, A keeps 56 of its 60 points (93%), B only 20 of its 100 (20%). With a little slippage, B loses money. This is one reason short-timeframe backtests can disappoint in live trading. A high win rate can hide the problem when the average win is small (the win-rate trap).
Stock research points the same way. Robert Novy-Marx and Mihail Velikov tested many anomalies, stock patterns that earned extra returns on paper. Most that traded less than half of their portfolio per month still earned returns after costs that were unlikely to be chance, at least when built to keep costs low; few that traded more did (NBER working paper 20721, published in the Review of Financial Studies, 2016). Crypto differs, but the arithmetic is the same.
Costs also change how you read optimization results (comparing many input settings). In our 2,000-combination study on BTC/USDT 4h, the best result made +11.27% from just 2 trades. At 0.2% per round trip, two trades cost 2 × 0.2 = 0.4 points; 100 trades would cost 100 × 0.2 = 20. Costs barely touch settings that rarely trade, so those can rise to the top of a ranked list. That is no sign of quality: two trades can easily be luck.
How to model costs in Pine Script
Pine Script v6 sets costs in the strategy() declaration, and users can override them on the Properties tab of the strategy settings (TradingView docs). Three parameters matter:
commission_type:strategy.commission.percent(the default) charges a percentage of each order's value, like crypto spot exchanges do.strategy.commission.cash_per_orderandstrategy.commission.cash_per_contractcharge fixed amounts instead.commission_value: with the percent type,0.1means 0.1%. The default is 0. It is applied to every filled order, so a round trip pays it twice (TradingView docs).slippage: a number of ticks (the smallest price step of a market) added to the fill price of market and stop orders, in the unfavorable direction. The default is 0. Limit orders are not affected; for them,backtest_fill_limits_assumptionmakes price move a set number of ticks past the limit before the order fills (TradingView docs).
//@version=6
// Costs: 0.1% commission per order plus 5 ticks of slippage.
// What 5 ticks means depends on the market: see "The tick trap" below.
strategy(
"Cost-aware EMA cross", overlay = true, initial_capital = 10000,
default_qty_type = strategy.percent_of_equity, default_qty_value = 10,
commission_type = strategy.commission.percent, commission_value = 0.1,
slippage = 5
)
int fastLen = input.int(9, "Fast EMA", minval = 1)
int slowLen = input.int(21, "Slow EMA", minval = 1)
float fast = ta.ema(close, fastLen)
float slow = ta.ema(close, slowLen)
if ta.crossover(fast, slow)
strategy.entry("Long", strategy.long)
if ta.crossunder(fast, slow)
strategy.close("Long")
// Not part of the trading logic: how many ticks equal 0.05% of the current price?
// The value appears in the Data Window.
float ticksFor005 = math.round(close * 0.0005 / syminfo.mintick)
plot(ticksFor005, "Ticks for 0.05% slippage", display = display.data_window)Without a limit or stop price, strategy.entry() sends a market order, and strategy.close() exits with one too, so test with your taker fee.
The tick trap
Tick sizes differ a lot. At the time of writing, Binance lists a tick size of 0.01 USDT for BTC/USDT and 0.00001 USDT for DOGE/USDT. In Pine, the tick size of your chart is syminfo.mintick (TradingView docs). For example:
- BTC at 80,000 USDT: 5 ticks = 5 × 0.01 = 0.05 USDT, which is 0.0000625% of the price. Practically nothing. Simulating 0.05% slippage would take 80,000 × 0.0005 ÷ 0.01 = 4,000 ticks.
- DOGE at 0.10 USDT: 0.05% of the price is 0.10 × 0.0005 = 0.00005 USDT, which is exactly 5 ticks.
So the same slippage = 5 matches our 0.05% example on DOGE and is almost zero on BTC. It also stays a fixed price distance even if the price doubles during your test. Too much is a problem too: TradingView notes that large constant slippage can push fills outside a candle's range and make results unrealistically bad (TradingView docs).
A simpler option is to fold slippage into the commission: with a 0.1% fee and about 0.05% slippage per side, set commission_value = 0.15 and slippage = 0. It is a rough approximation, but a percentage scales with the price. It also charges limit orders, which would not slip, so it errs on the cautious side.
Which numbers to test with
There is no universal slippage figure; it depends on the coin, the exchange, your order size and market speed. Some practical ways to choose:
- Fees: use your taker rate for market orders, and the maker rate only if your orders really rest in the book.
- Slippage: pick an assumption you can explain, for example 0.05% per side on a very liquid pair and more on smaller coins. These numbers are illustrations, not recommendations.
- Measure: if you trade live, compare each fill with the price your strategy expected, and update your assumption.
When you compare many input combinations, one by one in TradingView or in a batch tool such as PineTester, put the trade count next to net profit: the busiest settings pay the most costs. More in our parameter optimization guide.
Checklist
- Never test with zero costs. TradingView's defaults for commission and slippage are both 0.
- Use your real fee tier from your exchange's fee page, and the taker fee for market orders.
- Count the round trip. A fee of 0.1% per order costs about 0.2% per trade.
- Set
commission_type = strategy.commission.percentand put your fee incommission_value. - Convert slippage to ticks with
syminfo.mintick, or fold it into the commission percentage. - Check limit-order fills with
backtest_fill_limits_assumptionif your strategy relies on limit orders. - Compare the edge with the cost. If the average profit per trade is close to your round-trip cost, small cost changes decide the outcome (how to read backtest results).
- Stress-test with double costs. If profit flips to loss, the edge is thin. Be extra skeptical of high trade counts on short timeframes.
PineTester backtests the input ranges of your Pine Script v6 strategy on crypto spot data – up to your plan’s limit per backtest, a larger grid as a random sample – and every verdict on the results page names the documented method it rests on. Results can differ from TradingView’s Strategy Tester.
Test your strategy – one free backtestSimulated results on historical market data. Past performance is not indicative of future results. Not investment advice.