I Changed One Number in the Trailing Stop. The Strategy Went From −$1,560 to +$5,260.
The short version. Post #20 ended with an open item: the 2×ATR trailing distance was never tested — it was picked because 2 is a round number. This post tests it. Same script, same 4,089 bars, same 0.1% round-trip fee, three trailing distances — and the headline moves $6,820 on one number:
- 1×ATR: −$1,560.26, Profit Factor 0.753 — the tightest trail lost money. 51 trades, average hold 8.0 bars.
- 2×ATR: +$937.45, PF 1.117 — the middle, from #20.
- 3×ATR: +$5,259.95, PF 1.508 — the loosest trail made 5.6× the middle. But the win rate fell to 27.7%, and the median trade still loses money (−$221.97).
The fee is not the story this time: $322.50 / $359.12 / $427.20 across the three runs. The trail distance is the story — and it works through three mechanisms, not one: how much of a run-up you hand back, which exit fires first, and — the one I did not expect — which entries you ever get to take.
The contract: one question, chosen before I looked
Post #18's "What I couldn't verify" listed the trail distance second, word for word: "Trail distance: 2×ATR was picked, not tested. 1× and 3× are one-line changes." Post #20 answered the first item (costs). This post answers the second, and the fee stays on — Kamal asked in #20's comments for the sensitivity with the fee, and the #20 run is the 2× column of this test.
Three questions, in order:
- How much does the trailing distance move the headline — net, PF, win rate?
- Through what mechanism — give-back, the stop-vs-trail mix, or the entry stream itself?
- Is 3× "the answer", or just the best of three points?
The script is post #20's fixed RSI mean-reversion strategy, byte-identical apart from the trailing multiplier and the title string. Same 4,089 daily bars of CSI 300 (2010-01-04 → 2026-11-06), same $10,000, same PyneCore patched runtime, same 0.1% round-trip fee (0.05% per side, charged by the runtime on every fill). The hard stop stays fixed at 2×ATR below entry in all three runs — only the trail moves.
The one line that matters is close - atrVal * 2. Everything this post claims about "trailing distance" lives in that one number: 1, 2, or 3. If the result looks large, remember the change before you blame the strategy — one multiplier, nothing else touched.
The one-line change, in Pine — the trail level only, stop untouched:
var float trailLevel = na
inTrade = strategy.position_size != 0
if inTrade
trailLevel := na(trailLevel) ? close - atrVal * 2 : math.max(trailLevel, close - atrVal * 2)
else
trailLevel := na
1× and 3× change only the 2 in that line — to 1 and 3. And the compiled Python, verbatim from the local compiler (node bin/pine2pyne.mjs, zero diagnostics) — the only lines that differ from the #20 run:
# 1x:
trailLevel = ((close - (atrVal * 1)) if na(trailLevel) else math.max(trailLevel, (close - (atrVal * 1))))
# 3x:
trailLevel = ((close - (atrVal * 3)) if na(trailLevel) else math.max(trailLevel, (close - (atrVal * 3))))
A trailing stop is not a machine for keeping winners. It's a machine for pricing how much of a run-up you're willing to hand back before you leave — and the price is set by one number you probably never tested.
Probe 1: the headline — one number, $6,820 of difference
| 1×ATR | 2×ATR (#20) | 3×ATR | |
|---|---|---|---|
| Closed trades | 51 | 47 | 47 |
| Net profit | −$1,560.26 | +$937.45 | +$5,259.95 |
| Profit Factor | 0.753 | 1.117 | 1.508 |
| Win rate | 20 / 51 (39.2%) | 18 / 47 (38.3%) | 13 / 47 (27.7%) |
| Gross profit / gross loss | +$4,763.40 / −$6,323.66 | +$8,951.70 / −$8,014.25 | +$15,614.55 / −$10,354.60 |
| Avg win / avg loss | $238.17 / −$203.99 | $497.32 / −$276.35 | $1,201.12 / −$304.55 |
| Avg hold | 7.96 bars | 16.15 bars | 26.45 bars |
| Median trade | −$73.31 | −$172.61 | −$221.97 |
| Fees paid | $322.50 | $359.12 | $427.20 |
| Max equity drawdown | $3,534.99 (34.89%) | $2,231.62 (21.01%) | $2,839.78 (23.34%) |
| Top-5 winners' share | 73.2% | 67.6% | 66.3% |
| Net minus biggest winner | −$3,127.45 | −$936.86 | +$3,055.85 |
Three things to notice before the mechanisms.
First, the win rate goes the wrong way: 3× wins only 27.7% of its trades, the lowest of the three — and makes the most money. Average win grows five-fold from 1× to 3× ($238 → $1,201) while average loss grows by half ($204 → $305). The trail doesn't make the strategy right more often. It makes the right times pay more.
Second, the median trade loses money in all three runs. The strategy lives on its tail in every configuration — and only at 3× does it still stand without its biggest winner (+$3,055.85 net ex-biggest; 1× and 2× both go negative). Concentration is a property of the strategy, not of the parameter: top-5 share is 66–73% everywhere.
Third, 1× is the worst on every axis at once: it loses money and has the deepest drawdown ($3,534.99, 34.89% of equity). The tightest trail doesn't buy safety. It buys churn: 51 trades, 8-bar average holds, and the fee — though smallest in dollars — is the largest share of gross profit (6.8%, against 4.0% at 2× and 2.7% at 3×).
Probe 2: give-back — the price of holding longer
Give-back here means highest close since entry minus exit price, in index points, for every trail exit. It is the run-up you handed back before leaving.
| Give-back (points) | 1×ATR | 2×ATR | 3×ATR |
|---|---|---|---|
| Trail exits | 44 | 28 | 24 |
| Median | 99.83 | 156.60 | 230.94 |
| Mean | 114.27 | 157.37 | 243.94 |
| p90 | 200.51 | 264.98 | 435.72 |
| Max | 559.84 | 410.85 | 796.21 |
| ≤100 pts / 100–200 / >200 | 23 / 16 / 5 | 6 / 17 / 5 | 1 / 11 / 12 |
The give-back scales almost exactly with the multiplier — median 100 → 157 → 231 points. That is the mechanism working as designed: a wider trail lets price fall further from its high before you leave. And the cost is visible in the same table: at 3×, half the trail exits hand back more than 200 points.
But the give-back is not the loss. The loss would be handing back and not being compensated — and the compensation is in Probe 1: average win $238 → $497 → $1,201. The wider trail pays more give-back per exit and collects far more per winner. The trade is not "less give-back is better". The trade is "how much give-back buys how much extra win" — and on this data, 3× buys $963 of extra average win for $130 of extra median give-back per exit. Whether that exchange rate holds on other data is exactly what "What I couldn't verify" is for.
Probe 3: which exit fires first — the stop is fixed, the trail moves
The hard stop never moves: 2×ATR below entry, in all three runs. So changing the trail changes which exit fires first.
| Exit split | 1×ATR | 2×ATR | 3×ATR |
|---|---|---|---|
| Trail exits | 44 (20W, net +$437.43) | 28 (18W, net +$6,920.90) | 24 (13W, net +$13,633.04) |
| Stop exits | 7 (0W, net −$1,997.69) | 19 (0W, net −$5,983.45) | 23 (0W, net −$8,373.09) |
Stop exits never win in any run — 0 winners out of 49 stop exits across the three runs. That is not a parameter effect; it is the strategy's shape (mean-reversion entries that fail, fail fast).
Two conversions, matched trade by trade on the 46 entries common to all three runs:
- 1× converts 12 of 2×'s stop exits into trail exits. Every one of them is still a loser — but 1× loses less on 11 of the 12 (e.g. −$283.33 → −$142.42, −$411.77 → −$178.30, −$338.50 → −$113.01; the twelfth is identical at −$328.37). The tight trail fires before the stop can, and on a failing trade, leaving earlier is worth roughly half the loss.
- 3× converts 5 of 2×'s trail exits into stop exits. The trail is now looser than the stop, so the stop fires first — and 4 of the 5 lose more at 3× (−$172.68 → −$372.28, −$284.27 → −$384.27, −$254.46 → −$293.87, −$168.36 → −$257.32; the fifth is identical at −$517.59). A trail wider than the stop is a trail that sometimes never gets to fire.
The decomposition on the 46 common closed trades makes the point numerically: 2× → 1× is −$1,864.30, of which +$684.38 comes from the 16 trades that exit on the same bar (sizing and fee path only) and −$2,548.68 from the 30 that exit on a different bar. 2× → 3× is +$3,630.56, of which −$982.46 is same-bar and +$4,613.02 is different-bar. The trail distance does its damage and its good almost entirely through when you leave, not through how many contracts you hold.
Probe 4: the entry stream itself changes — including a second silent drop
This is the mechanism I did not expect. The entry signal is identical in all three runs — RSI crossing up through 30, same bars, same prices. But the entries are not identical: 1× takes 52 entries, 2× and 3× take 48. Three mechanisms inside that gap:
1× exits sooner, so it gets three entries the others never see. Bars 850, 981 and 1338 are RSI crossovers that fire while 2× and 3× are still sitting in the previous trade. 1×, already out, takes them: +$41.19, −$15.84, −$458.21 — net −$432.86. The tight trail doesn't just exit earlier; it frees the slot for the next signal, and on this data the freed slot lost money.
Bar 486: 3× silently drops an order — the second silent drop in this series. At the 2011-12-30 signal, 3× equity was $9,402.97 — higher than 1× ($8,503.30) and 2× ($8,388.95). Higher equity sized 4 contracts (floor($9,402.97 / 2,345.74) = 4); 4 × $2,361.50 (the 2012-01-04 open) = $9,446.00 — $43.03 more than the account held. The order was dropped, silently. 1× and 2× sized 3 contracts ($7,084.50) and filled — and lost −$294.07 on it. Same gate as #20's $51.41 drop, $43.03 this time, and the irony is exact: 3× was dropped because it was ahead. The affordability gate is not a property of the fee. It is a property of the equity path — and the trail distance moves the equity path.
Bar 1373: the #20 dropped entry, filled twice. The 2015-08-28 signal that #20's fee run dropped (equity $9,687.31, $51.41 short of 3 contracts) fills in both other runs: at 1×, equity $7,607.39 sized 2 contracts ($6,492.48) and the trade lost −$200.56; at 3×, equity $10,950.27 sized 3 contracts ($9,738.72) and the trade won +$397.88. One gate, three outcomes, decided entirely by where the equity path happened to be.
Totalled up: 1× net −$1,560.26 breaks into −$632.78 on the 46 common closed trades and −$927.47 on its 5 non-common ones (bar 486 −$294.07, the three extra entries −$432.86, bar 1373 −$200.56; the parts sum to the total up to a cent of rounding). 3× net +$5,259.95 = +$4,862.07 common + $397.88 (bar 1373). The entry-stream effects are not rounding. They are hundreds of dollars in each direction, and they are invisible if you only compare headline tables.
So is 3× the answer?
No — and saying so would be exactly the mistake this series exists to avoid. Three points are a sensitivity test, not an optimum. 3× is the best of three, on one script, on one market, on 4,089 bars, with the fee at one level. Picking the best of three and reporting it as "the answer" spends the validation budget the same way tuning 20 → 35 → 42 days spends it: you found the numbers that happened to work on data you've now already seen.
What the three points do establish, in our testing:
- The trailing distance is a first-order parameter, not a detail: $6,820 of headline on one multiplier.
- The mechanism is threefold and measurable: give-back per exit (median 100 → 157 → 231 points), which exit fires first (stop exits 7 → 19 → 23), and the entry stream itself (silent drops and freed slots move hundreds of dollars).
- The middle value is not special. 2× was picked because 2 is a round number, and it happens to sit in the middle of the range — not because anything about the data says 2.
What I couldn't verify
- No optimum. 3 points can't tell you about 2.5× or 4×, and I won't interpolate one. The next test that would actually answer "what distance" needs a finer grid and a held-out sample — otherwise it's tuning, not testing.
- One market, one script. CSI 300 daily, one RSI mean-reversion script. A trend-following entry would punish a loose trail differently; a faster market would punish it more.
- One fee level. All three runs carry the same 0.1% round trip. The fee interacts with the trail through the equity path (Probes 3–4 are both sizing-path effects), and that interaction at other fee levels is untested.
- The stop is still untested. The hard stop stayed at 2×ATR throughout. A 3× trail with a 3× stop is a different strategy from a 3× trail with a 2× stop, and this post says nothing about it.
- The give-back exchange rate is sample-bound. "3× buys $963 of extra average win for $130 of extra median give-back" is one sample's price. It is not a rule.
Bottom line
2×ATR was never a decision. It was a default — and on this data, the default sits $4,322.50 below the looser setting and $2,497.71 above the tighter one, in our testing. The lesson is not "use 3×". The lesson is the discipline: a parameter you never tested is a parameter you chose by feel, and feel is the most expensive way to pick a number in a backtest. Test the distance — all of it, including the entries it quietly adds and drops — or admit you didn't.
Next post (#22): Kamal's split test from #20's comments — when an order doesn't fit the account, fill it at the close price or shrink it to what fits? Both, measured on the same #20 trade. After that, the random-entry placebo.
Disclosure: I built Pine2Py (pine2py.com), the Pine Script → Python converter this series runs on. The strategy in this post is a test script, not a recommendation; nothing here is investment advice, and past backtest results don't predict anything. Free accounts get 3 conversions total; Pro is $12/month via Paddle. The runs above used the patched PyneCore runtime build provided on the site (stock PyPI PyneCore is not supported). All numbers are from local runs on 2026-11-27, in our testing: 1,909 real-world scripts compile at 99.7% and fully translate at 98.4%.
Top comments (0)