Guide · 2 min read
The costs a TradingView backtest leaves out
Out of the box, the Strategy Tester trades for free: no commission and no slippage. A live account pays both on every fill. On small futures trades, those costs can be a large share of the average result.
What the tester charges by default
A Pine strategy has two cost settings, in the script's strategy() call or on the strategy's Properties tab:
- Commission (
commission_type,commission_value): per contract, per order, or a percentage. The default is 0. - Slippage (
slippage): a fixed number of ticks added against you on market and stop orders. The default is 0.
The List of trades' Net P&L (Profit, in older exports) includes them only if they're set. A strategy with the defaults shows results before all costs.
What a tick is worth
Slippage is measured in ticks, but it's paid in dollars. The tick value depends on the contract:
| Contract | Tick size | Point value | One tick, per contract |
|---|---|---|---|
| MES (Micro E-mini S&P 500) | 0.25 | $5 | $1.25 |
| MNQ (Micro E-mini Nasdaq-100) | 0.25 | $2 | $0.50 |
| ES (E-mini S&P 500) | 0.25 | $50 | $12.50 |
| NQ (E-mini Nasdaq-100) | 0.25 | $20 | $5.00 |
One tick against you on entry and one on exit is two ticks per round trip: $2.50 per contract on MES, $25 on ES.
A worked example
Take a strategy on 2 MES contracts whose tester trades average $15 each with no costs set. Suppose live fills average one tick worse on each side, and commission (an example figure, not IBKR's rate) is $0.60 per contract per side.
| Slippage: 2 ticks × $1.25 × 2 contracts | $5.00 |
| Commission: 4 fills × $0.60 (2 contracts in, 2 out) | $2.40 |
| Cost per round trip | $7.40 |
| Average tester trade | $15.00 |
| Average after costs | $7.60 |
In this example, about half the tester's average trade goes to costs it didn't model. The numbers are illustrative; your own fills give the real ones.
Measuring the real costs from your files
- Commission is in the IBKR Flex Query's IB Commission column, one value per fill. It's negative because it's a charge. Sum it over each trade's entry and exit fills.
- Slippage is the fill price minus the tester's price, signed so that worse is positive (higher for a buy, lower for a sell). Divide by the tick size for ticks, and multiply ticks by the tick value and the filled quantity for dollars.
- Keep them apart. Commission is fixed by your rate. Slippage depends on order type, timing and the market. Lumped together, it's hard to see which one changed.
Look at the median as well as the average. One bad fill in a fast market can pull the average far from a typical trade.
Before or after commission?
To compare live with the tester, use the same footing on both sides. If the strategy sets no commission, the tester's results are before commission. Live results compared after commission then include the commission as part of the gap. That's correct, but name it, so a commission line isn't read as bad fills.
Trade Teardown shows slippage in ticks and dollars and commission separately, per trade and per hour of the day, from your TradingView and IBKR files, in your browser.