Backtesting guide
Slippage in TradingView backtests
Slippage in trading is the difference between an expected execution price and the actual fill. TradingView models it with a fixed number of ticks on market and stop orders. Convert those ticks using the instrument specifications, separate costs already included in the fill, and test whether the strategy remains profitable under worse execution assumptions.
Read the practical guideKey Takeaways
- A tick is a price increment. Its cash value also depends on quantity and the contract multiplier.
- Commission, spread and slippage describe different costs, but a measured fill difference can already include spread.
- Use a documented baseline and an adverse scenario; no single tick setting fits every instrument or order size.
- A limit price constrains the execution price but can leave the order unfilled.
Convert ticks before entering a cost assumption
For a linear instrument, let n be adverse slippage ticks, t the minimum price increment, Q the absolute filled quantity, V the cash value of a one-point move per unit, and P a positive reference price. Read tick size and point value from the exact symbol or contract specification. Account-currency conversion, inverse contracts and other nonlinear payoffs require additional calculations.
| Measure | Calculation | Hypothetical example |
|---|---|---|
| Price movement | n × t | 2 ticks × $0.01 = $0.02 per share |
| Cash cost per fill | n × t × Q × V | $0.02 × 100 shares × 1 = $2 |
| Percentage of reference price | 100 × n × t ÷ P | 100 × $0.02 ÷ $100 = 0.02% |
| Basis points | 10,000 × n × t ÷ P | 2 basis points at a $100 reference price |
| Contract multiplier example | 2 × 0.25 × 3 × $50 | $75 per fill for 3 hypothetical contracts |
- Two ticks is 0.50 points when the tick size is 0.25; it is not two points or 2%.
- An equal-size entry and exit with the same adverse adjustment incur twice the per-fill cash cost. Partial exits and reversals require counting every filled quantity.
- The same $0.02 price adjustment is 0.2% at $10 and 0.02% at $100. Fixed ticks cannot maintain a fixed percentage through a large price change.
Separate commission, spread and residual slippage
Commission is an explicit fee. Spread is the difference between bid and ask; a market buy generally executes near the ask and a market sell near the bid. Define the reference used to measure slippage. A fill measured against a midpoint can include the spread, while slippage measured beyond the executable quote is a separate adjustment.
| Cost | Modeling choice | Double-counting check |
|---|---|---|
| Commission | Percent of transaction value, cash per unit, or cash per order | Confirm whether the broker quote is per side or round trip. |
| Spread | For a midpoint example, charge half the spread on each side | Do not subtract it again if entry and exit already use ask and bid. |
| Residual slippage | Adverse price movement beyond the chosen quote benchmark | Do not add it to a total observed fill shortfall that already includes it. |
| Other costs | List exchange fees, financing, borrow and currency conversion separately | Record omissions; a fixed tick offset does not reproduce time-dependent fees. |
A reproducible baseline and stress comparison
This arithmetic example buys and later sells 100 shares, using midpoint references of $100 and $101, a $0.01 tick and a multiplier of 1. Gross profit is ($101 − $100) × 100 = $100. Assume equal spreads at entry and exit, adverse residual slippage on both fills, and two filled orders. All values are hypothetical; financing, taxes and other fees are excluded.
| Round-trip component | Baseline | Stress scenario |
|---|---|---|
| Commission per order | $1.00 | $1.50 |
| Full spread per share | $0.02 | $0.06 |
| Residual slippage per fill | 2 ticks = $0.02 per share | 5 ticks = $0.05 per share |
| Commission total | 2 × $1.00 = $2 | 2 × $1.50 = $3 |
| Spread total | 100 × ($0.01 + $0.01) = $2 | 100 × ($0.03 + $0.03) = $6 |
| Residual slippage total | 2 × 100 × $0.02 = $4 | 2 × 100 × $0.05 = $10 |
| Total cost | $2 + $2 + $4 = $8 | $3 + $6 + $10 = $19 |
| Net profit | $100 − $8 = $92 | $100 − $19 = $81 |
| Cost / $10,000 entry reference notional | 0.08% = 8 basis points | 0.19% = 19 basis points |
- Check the baseline another way: buy at $100.03, sell at $100.97, then deduct $2 commission. The result is $92.
- The stress fills are $100.08 and $100.92. Their $84 profit before commission becomes $81 after the $3 fee.
- With these fixed quantities and cash fees, an otherwise identical trade with only $15 gross profit would retain $7 at baseline and lose $4 under stress. This is cost sensitivity, not a forecast.
Apply the assumptions in TradingView
Open the strategy settings and inspect the commission and slippage fields in Properties or Broker Emulator, depending on the interface. TradingView applies commission on entry and exit. A percentage commission value of 0.05 means 0.05%, so a $10,000 transaction costs $5. Cash per order and cash per contract use different bases.
- The built-in slippage field is a tick count for market and stop fills. In the midpoint example, combined half-spread plus residual slippage would be 3 ticks per fill at baseline and 8 under stress. This approximation is valid only if the reference and order model match; chart prices are not automatically midpoint quotes.
- If one tick setting represents both spread and residual slippage, do not deduct the spread again. Keep the breakdown in the research record even when the platform combines it.
- A fixed adverse adjustment can produce simulated fills outside a candle. Inspect individual trades and choose assumptions from execution evidence, rather than increasing ticks until an attractive result disappears.
Test limit fills separately from slippage
TradingView limit verification requires price to move a specified number of ticks beyond the limit before accepting a fill at the limit. The default zero accepts a touch. For a resting $100 buy limit, $0.01 ticks and a verification setting of 2, the qualifying price is $99.98; the modeled limit fill remains $100. This is a fill test, not a two-tick execution discount.
- For a resting sell limit at $101, the equivalent threshold is $101.02. Avoid applying the market-order cost table unchanged to passive limit fills.
- A real limit order may remain unfilled because liquidity or queue position prevents execution. Verification does not reconstruct an exchange queue or partial fills.
- Compare trade count and the omitted trades as well as net profit. Stricter verification can delay fills and change the sample; it is not equivalent to subtracting a fee from the original trades.
Save each run and reconcile the trade records
Hold the symbol, timeframe, date range, rules and position sizing fixed while comparing cost scenarios. Change one assumption at a time to identify its effect, then run the combined adverse scenario. Record net profit, drawdown and closed-trade count alongside the cost settings. If costs change equity-based sizing or order eligibility, rerun the strategy instead of subtracting a constant from the old report.
- Calibrate by instrument, session, order type and size using available quotes and execution records. A quiet-session estimate may be unsuitable around a gap or news event.
- Import each compatible TradingView trade CSV into Backtest Deep Report and reconcile closed-trade count and net profit first. Its drawdown calculations use the imported trade record; they do not reconstruct intrabar account equity.
- Keep the cost table independently. An exported net P&L series alone cannot identify how much came from commission, spread or residual slippage, and analysis cannot repair omitted costs.
Related Pineify workflow
Review the trade results after setting execution costs
Backtest Deep Report analyzes compatible TradingView trade CSV files for profit and risk measures. Pine Script AI Coding Agent can help revise strategy code when the cost assumptions require a code change.
Inspect imported net profit, drawdown and trade results for each saved cost scenario.
Analyze a trade CSVDescribe the required commission and execution assumptions for a reviewable code revision.
Edit the strategyBoundary: Supply and verify the cost assumptions yourself. CSV analysis does not infer broker fees, attribute slippage, or guarantee live execution; generated code still needs syntax and behavior checks.
Primary sources
- TradingView: Strategy properties and execution costsVerified 2026-10-17
- TradingView: Slippage and unfilled limit ordersVerified 2026-10-17
- TradingView: Broker emulator settingsVerified 2026-10-17
- CME Group: Tick size and cash valueVerified 2026-10-17
- Investor.gov: Market, limit and stop ordersVerified 2026-10-17
This page is educational and does not provide investment advice. Backtests are hypothetical, depend on their data and assumptions, and do not guarantee future results. Trading can result in substantial loss.