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.
| Rule | Fixed stop | Trailing stop used here |
|---|
| Initial stop | $95 | $95 |
| Reference price | Entry price of $100 | Highest confirmed close since entry, starting at $100 |
| Distance | $5 below entry | $5 below the reference close |
| Update | None | At each bar close, while still in the trade |
| Activation | Active from the start of each example | Revised level is active from the next bar |
| Adverse move | Stop remains $95 | Stop 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 / close | Fixed stop during bar | Trail during bar | Trail after close |
|---|
| 1: 100 / 104 / 100 / 104 | 95; survives | 95; survives | 99 |
| 2: 104 / 110 / 104 / 110 | 95; survives | 99; survives | 105 |
| 3: 110 / 110 / 104 / 104 | 95; survives to deadline | 105; fills on the decline | Trade 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.
| Outcome | Trailing version | Fixed 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 | -$60 | Same 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.