TradingView Backtesting

Trailing stop vs stop loss: compare the same trade

A trailing stop is a stop loss whose level follows favorable price movement; a fixed stop stays at its original level until you change it. A trail can reduce profit giveback, but it can also exit during a pullback before the trend resumes. Compare them in TradingView with the same entry, quantity, initial risk, and costs. Neither stop guarantees its trigger price as the fill price.

Write the exit comparison

Freeze the inputs that could change the answer

The examples below are invented long trades, not observed backtests. Each starts with 10 shares filled at $100 and a $95 stop already active before the next bar. Initial planned risk is (100 - 95) × 10 = $50. Both versions use a stop-market exit, no target, no additional entries, no leverage, and the same terminal exit deadline. Baseline calculations exclude fees and slippage; a separate cost example adds them.

  • For a surviving long trade: next stop = max(previous stop, current confirmed close - $5). This is a custom close-based trail, not a simulation of every broker trailing order.
  • Check the existing stop during the bar first. If it fills, the closing price cannot resurrect the trade or revise that exit.
  • All prices are in USD per share. The $5 distance is fixed in dollars, not 5% of every new reference price.
RuleFixed stopTrailing stop used here
Initial stop$95$95
Reference priceEntry price of $100Highest confirmed close since entry, starting at $100
Distance$5 below entry$5 below the reference close
UpdateNoneAt each bar close, while still in the trade
ActivationActive from the start of each exampleRevised level is active from the next bar
Adverse moveStop remains $95Stop never moves down

A retracement gives back part of the open profit

Assume continuous price movement inside each bar and no gaps. The long position exists before bar 1. For this arithmetic experiment, any survivor is liquidated at bar 3 close, $104; that terminal fill is an explicit assumption, not a claim about the default timing of a Pine market order.

  • Peak open profit before the decline = (110 - 100) × 10 = $100.
  • Trailing exit: (105 - 100) × 10 = +$50. Giveback from the peak is $100 - $50 = $50.
  • Fixed version at the common deadline: (104 - 100) × 10 = +$40. Giveback is $100 - $40 = $60.
  • The trail retains $10 more in this path. If the fixed version were allowed a later deadline, it would be a different experiment.
Bar: open / high / low / closeFixed stop during barTrail during barTrail after close
1: 100 / 104 / 100 / 10495; survives95; survives99
2: 104 / 110 / 104 / 11095; survives99; survives105
3: 110 / 110 / 104 / 10495; survives to deadline105; fills on the declineTrade closed

A brief pullback can make the trail worse

Start a new, independent trade with the same $100 entry, 10 shares, and $95 initial stop. Bar 1 is 100 / 103 / 100 / 103, so the trail rises to $98 for bar 2. Bar 2 is 103 / 104 / 97.50 / 104. Under either possible high-low ordering, the active $98 stop is crossed; the fixed $95 stop is not. The common deadline is bar 2 close at $104.

  • A tighter stop reduced the loss relative to the initial $50 risk but also removed the position before recovery.
  • Do not add an immediate re-entry only to the trailing version. That changes the entry policy and introduces another trade and its costs.
  • These two paths establish a tradeoff, not the frequency of either outcome. Estimate frequency from a separate, predefined historical sample.
OutcomeTrailing versionFixed version
Exit price under stated assumptions$98 at the stop$104 at the deadline
Gross P/L(98 - 100) × 10 = -$20(104 - 100) × 10 = +$40
Difference: trailing minus fixed-$60Same entry and quantity

A gap can cross both stops before either can fill

Take the first example through bar 2: the last close is $110, the fixed stop is $95, and the updated trail is $105. Now replace bar 3 with a gap to an open of $92. TradingView documents that an active price-based order crossed in the interbar gap fills at the new open. With no extra slippage, both versions therefore exit at $92 and lose (92 - 100) × 10 = $80.

  • The fixed stop planned a $50 loss; the gap adds $30. The trail indicated a $50 gain at its trigger, but the $92 fill is $130 worse than that trigger-based estimate.
  • Add a hypothetical $1 commission per side and $0.02 adverse exit slippage per share, keeping the already-filled entry at $100: net P/L = (91.98 - 100) × 10 - 2 = -$82.20.
  • With a $0.01 tick size, $0.02 equals two ticks. A different tick size changes that conversion. A Pine slippage setting can affect the entry too, so reconcile the actual entry fill rather than assuming it stays $100.
  • Real broker stop triggers, session eligibility, available liquidity, and order handling require separate verification. A stop-limit variant can remain unfilled and is outside this stop-market comparison.

An intrabar trail answers a different question

TradingView distinguishes built-in trailing stops from custom stops updated at bar close. The built-in trail has an activation threshold and a tick-based offset; it can respond to live price updates, while historical results rely on simulated price movement. Our tables deliberately use confirmed closes. Changing that reference or timing changes the rule being tested.

  • Suppose the previous stop is $95 and the next bar is 100 / 110 / 96 / 101. The close-based rule keeps $95 throughout that bar, survives, and sets $96 for the next bar.
  • A $5 intrabar trail already activated at $100 could rise to $105 after the $110 high. A subsequent decline can then exit at $105. Whether the high precedes the low needs intrabar evidence or a stated emulator path.
  • Do not apply a stop calculated from the current bar close to an earlier low in that same bar. That uses information unavailable when the low occurred.
  • If a trail activates only after a profit threshold, specify the protective stop before activation. Otherwise its initial downside exposure differs from the fixed-stop version.

Run a comparison you can reconcile

First compare exits on a fixed list of entry events. Give each event the same fill price, quantity, and evaluation deadline in both versions. In an ordinary strategy, a longer holding period can block the next entry, so identical entry code alone does not guarantee an identical trade sample. Check actual entry timestamps and fills before interpreting totals.

  • Save symbol and exchange, standard chart type, timeframe, session, date range, data coverage, code version, and all strategy properties. Freeze calculation frequency, order timing, bar detail, and costs.
  • Record each stop before the bar, the price used to revise it, the revision time, trigger, and actual simulated fill. For longs, a decrease in the trailing stop indicates a different rule or a bug.
  • Report paired net P/L, peak open profit minus exit profit, holding time, and exits followed by recovery before the common deadline. Label the recovery measure as retrospective analysis, never an entry signal.
  • Test a preselected range of distances on one period, then keep the chosen rule fixed for a later holdout period. Include quiet, trending, and gap-heavy intervals instead of selecting only the path that favors a trail.
  • After the paired test, run each complete strategy with its own resulting entry availability. Report that as a portfolio-level consequence of the exit rule, separately from the controlled exit comparison.

Use the comparison to make the rule explicit

A fixed stop fits a hypothesis that fails at a specified price while allowing smaller pullbacks. A trailing stop fits a rule that exits after a specified retreat from favorable movement. Neither choice follows from one profitable example. Decide how much giveback and early-exit frequency your tested rule permits, then check the result after costs on unseen data.

  • For Pine Script AI Coding Agent, describe the unchanged entry rule, fixed quantity, initial stop, trail reference, update time, and deadline. Review the generated strategy and validate its fills against a few hand-calculated trades.
  • In Trading Journal, save planned risk and initial stop, then use plan and review notes for the exit variant, update rule, trigger, actual fill, costs, and reason for any difference. Keep simulated examples clearly labeled.
  • Pineify can help write rules and record trades. These steps do not place broker orders or replace broker margin and execution rules.
Where Pineify fits

Pine Script AI Coding Agent

Describe both exit rules with the same entry and position size, then review the generated Pine strategy. Check stop units, update timing, and individual fills before comparing the reports.

Also useful: Trading Journal. Record planned risk, the initial stop, and trade results. Use plan and review notes to preserve the exit rule and explain gaps between intended and actual fills.

Write the exit comparison

Frequently asked questions

Educational information, not investment advice. The prices, fees, and outcomes are hypothetical arithmetic examples, not measured strategy performance. Backtests and stop orders do not guarantee live fills or future returns.

Sources and verification

Published by Pineify. Pineify is an independent product and is not affiliated with TradingView. Sources support the technical explanations; examples do not establish trading performance.