Commission and slippage in Pine Script, explained
Commission is the broker's fee on each order; slippage is the gap between the price your rule saw and the price you get. Pine charges neither unless you set them: commission_type and commission_value set the fee, and slippage adds a fixed number of ticks against you on every market and stop order. On an RSI(2) strategy on SPY, 0.05% commission and 0.025% slippage on each side cut ten years' return from 42.8% to 24.8%.
The three settings
All three go in the strategy() declaration.
| Setting | Default | What it does |
|---|---|---|
| commission_type | percent | What commission_value counts: strategy.commission.percent for a percent of the order's value, strategy.commission.cash_per_contract for money per contract or share, strategy.commission.cash_per_order for money per order. |
| commission_value | 0 | The fee, in the unit commission_type sets. With the percent type, 0.05 is 0.05% of each order. |
| slippage | 0 | Ticks added against you on every market and stop order: a long fills higher, a short lower. |
Anyone running the script can change all three in the strategy's Settings, under Properties, so the declaration sets where a test starts, not what it must use.
strategy("My strategy", overlay = true,
commission_type = strategy.commission.percent,
commission_value = 0.05, // 0.05% of each order's value
slippage = 19) // ticks: 19 × $0.01 is about 0.025% of SPY at $766.54Slippage is in ticks, so its cost depends on the price
A tick is the smallest price step, $0.01 on US stocks. Because slippage counts ticks, the same setting costs a different share of the price on every symbol:
| Price | One tick is | Ticks for 0.025% |
|---|---|---|
| SPY at $766.54 (19 Oct 2026) | 0.0013% | 19 |
| A $100 stock | 0.01% | 2.5 |
| A $20 stock | 0.05% | 0.5 |
So slippage = 1 is close to nothing on SPY, and on a $20 stock it is already twice our default, with no setting in between: the argument takes whole ticks. A fixed tick count also drifts as the price moves. The 19 ticks that are 0.025% of SPY at $766.54 were about 0.09% in January 2016, when SPY closed at $200.99, so a ten-year test charged its early trades nearly four times what it charged its late ones.
To charge the same share of the price on every symbol and in every year, put the slippage into the percent commission instead, which TradingView charges on every filled order:
// the same 0.075% on every fill, whatever the price:
// commission and slippage together, charged as commission
strategy("My strategy", overlay = true,
commission_type = strategy.commission.percent,
commission_value = 0.075,
slippage = 1) // one tick, so no fill lands at the exact priceWhat to charge
Our tester charges 0.05% commission and 0.025% slippage on each side unless a script sets its own commission: 0.15% for a round trip, a conservative figure for liquid large US stocks. A broker that charges no commission still fills you at the spread, so zero is never the right number. Charge more on thinner stocks, wide spreads and fast opens, and use strategy.commission.cash_per_contract if your broker bills per share.
What costs did to one strategy
The RSI(2) pullback on SPY from the how-to, longs only, 90 trades from 4 January 2016 to 19 October 2026, run at six levels of cost in our engine:
| Each side | Round trip | Net | Profit factor | Average trade | Tester's verdict |
|---|---|---|---|---|---|
| No costs | 0% | +42.8% | 2.10 | +0.41% | Real edge so far |
| 0.025% + 0.0125% | 0.075% | +33.5% | 1.85 | +0.33% | Could be luck |
| 0.05% + 0.025% | 0.15% | +24.8% | 1.62 | +0.26% | Could be luck |
| 0.10% + 0.05% | 0.30% | +9.2% | 1.23 | +0.11% | Could be luck |
| 0.15% + 0.075% | 0.45% | −4.6% | 0.92 | −0.04% | Lost money |
| 0.20% + 0.10% | 0.60% | −16.6% | 0.67 | −0.19% | Lost money |
Before costs the average trade made 0.41%, so the strategy breaks even somewhere between a 0.30% and a 0.45% round trip. A rule whose average trade sits close to its cost is mostly a test of the cost. At our default the tester's verdict moved from “real edge so far” to “made money, but could be luck”. A strategy that trades rarely and makes several percent a trade barely notices the same 0.15%.
Questions
None. commission_value defaults to 0, so a strategy that does not set it pays nothing on its fills. commission_type defaults to strategy.commission.percent, so commission_value = 0.05 means 0.05% of each order's value.
As a fixed number of ticks. The slippage argument, 0 by default, is multiplied by the symbol's tick size and added against you on every market and stop order: higher on a long entry, lower on a short one.
No. TradingView adds slippage to market and stop orders. For limit orders it has a separate setting, backtest_fill_limits_assumption, the number of ticks price must pass a limit before it fills there.
Our tester's default is 0.05% commission and 0.025% slippage on each side, 0.15% a round trip, a conservative figure for liquid large US stocks. Charge more on thinner names. If your broker bills per share, use strategy.commission.cash_per_contract.
Sources, read on 20 October 2026: TradingView's Pine Script manual, “Strategies” (commission, slippage, limit-order fills), and the Pine Script v6 reference for strategy() (the three commission types, slippage on market and stop orders, both defaults). The numbers are our engine's, run on 20 October 2026 on our daily data. A backtest describes the past; it is not a forecast or advice. TradingView belongs to its owner, and Alpha Charts is not affiliated with it.