DEV Community

Lei Chen
Lei Chen

Posted on

38 of 58 Exits Were the Stop. Widening the Target Fixed Nothing.

38 of 58 Exits Were the Stop. Widening the Target Fixed Nothing.

TL;DR: Post #12 ended with a question: how often does the 2×ATR limit fire first versus the 1×ATR stop, and what happens when the limit widens? I counted every exit by reason on the daily feed. The stop fired 38 of 58 times and never won once — all 38 exits lost a combined −$6,153.94. Widening the limit from 2× to 4×ATR moved the net only from −$2,572.67 to −$1,998.77, because the limit wins didn't grow — they turned into time exits. And 18 of those 38 stops filled below the stop level itself, costing an extra $1,094.28. The bracket's problem was never the target. It was the stop.

Limit Closed trades Limit exits Stop exits Time exits Net profit Profit Factor
2×ATR 58 14 38 6 −$2,572.67 0.587
3×ATR 58 8 39 11 −$2,290.95 0.639
4×ATR 58 2 39 17 −$1,998.77 0.700

The setup: one number changed, nothing else

The script is post #5's fixed RSI mean-reversion strategy, byte-identical apart from the limit multiplier — the compiled .py for each variant diffs clean against the 2× version except for one number (atrVal * 2 → * 3 → * 4) and the title string. Zero diagnostics from the local compiler on all three. Same 4,089 daily bars of CSI 300 (2010-01-04 → 2026-11-06), same $10,000, same PyneCore patched runtime, no commission, no slippage. The entries are identical across all three runs — all 59 entries, same bars, same prices — so every difference below is purely an exit difference.

if inTrade
    strategy.exit("Exit Long", "Long", limit=strategy.position_avg_price + atrVal * 2, stop=strategy.position_avg_price - atrVal)
    if barsInTrade >= maxHold
        strategy.close("Long", comment="Time exit")
Enter fullscreen mode Exit fullscreen mode

One thing the script does that is easy to miss: the bracket levels are recomputed from the current bar's ATR every bar. The level that actually fills you is set on the bar where the exit order is placed — the previous bar's ATR, not the entry bar's. I verified that directly: every non-gap bracket fill in all three runs lands exactly on the level computed from the previous bar's ATR (distance 0.0000 ATR), and the fills that don't match are the ones that opened beyond the level. That check is what makes the counting below exact instead of approximate.

What you're checking here:

  • How often does each exit reason actually fire — limit, stop, or time?
  • When you widen the limit, do the stops go away, or does something else absorb the trades?
  • How much of the loss is the stop level itself, and how much is filling past it?

Probe 1: the exit split at 2×ATR — the stop is the strategy

Exit reason Trades Wins Net Avg per trade Avg hold
Limit (2×ATR) 14 14 +$2,735.40 +$195.39 3.2 bars
Stop (1×ATR) 38 0 −$6,153.94 −$161.95 2.7 bars
Time (10 bars) 6 5 +$845.87 +$140.98 10.0 bars

Read that table as a strategy, not as a bracket. Two out of three trades (38 of 58, 65.5%) end at the stop, and the stop has never once produced a winner — by construction it can't, since the fill is always below the entry. The limit is perfect in its own small way (14 for 14, +$195.39 average), and the time exit is quietly the second-best exit in the system (5 of 6 wins). But neither matters, because the stop fires more than twice as often as the other two combined, and its average loss (−$161.95) is nearly the size of the limit's average win (+$195.39).

The shape of the loss is also in the table: the stop fires fast (2.7 bars on average) while the limit takes 3.2. The strategy doesn't bleed slowly. It gets stopped out quickly, over and over, and the occasional limit win can't cover 38 small cuts.

Probe 2: widen the limit 2× → 3× → 4× — the stops don't move

2×ATR 3×ATR 4×ATR
Limit exits 14 (+$2,735.40) 8 (+$2,095.68) 2 (+$551.56)
Stop exits 38 (−$6,153.94) 39 (−$6,258.25) 39 (−$6,578.53)
Time exits 6 (+$845.87) 11 (+$1,871.62) 17 (+$4,028.20)
Net −$2,572.67 −$2,290.95 −$1,998.77
Profit Factor 0.587 0.639 0.700
Win rate 19 / 58 (32.8%) 17 / 58 (29.3%) 17 / 58 (29.3%)

Widening the limit does exactly one thing: it moves trades from the limit column to the time-exit column. The limit count falls 14 → 8 → 2, the time-exit count rises 6 → 11 → 17, and the stop count sits at 38 → 39 → 39, essentially frozen. The net improves by $574 across the whole doubling, and the Profit Factor crawls from 0.587 to 0.700 — still below 1.0, still losing, still below buy & hold (+$1,468.22 on the same span).

The interesting cell is the one nobody tunes for: at 4×ATR, the time exit is the best exit in the system — 17 trades, 15 wins, +$4,028.20 net, +$236.95 average. It wins by accident. The trades that used to hit the 2× limit now survive to bar 10, and bar 10 turns out to be a better exit than the limit was. That is not a finding about the time exit. It is a finding about how little the limit was doing: remove it, and the strategy gets better, because the 10-bar close catches what the limit caught, plus a little more.

Two honesty notes before this table persuades anyone. First, the limit multiplier was chosen after seeing the 2× result, so this is exploration, not a confirmation — the same post-hoc label post #12 put on the weekly test. Second, the win rate falls as the limit widens (32.8% → 29.3%): fewer wins, but bigger ones. A wider target that "improves" the net while cutting the win rate is not a better strategy. It is the same strategy with its wins re-labeled.

Probe 3: the stop level is not the fill price

Of the 52 bracket exits at 2×ATR, 19 filled at the exit bar's open, not at the limit or stop level — the bar opened beyond the level and PyneCore filled at the open. Eighteen of those were stops. The gap-through cost, measured against the level the script actually set:

Gap fills Extra vs level
Stop exits 18 of 38 −$1,094.28 (filled below the stop)
Limit exits 1 of 14 +$41.32 (filled above the limit)
Net gap effect 19 of 52 −$1,052.96

$1,094.28 is 42.5% of the strategy's entire net loss. Nearly half of what this strategy loses is not the bracket design — it is the market opening past the stop. The worst single case is trade #3: the stop sat at 2945.17, the bar opened at 2835.88, and the fill was 109.29 points below the stop — an extra $327.87 on that one trade alone, at 3 contracts.

The same mechanism runs in reverse on the weekly feed, and it rewrites post #12's headline trade. Trade #12 — the +$1,937.34 week in September 2024 that was 61.5% of the weekly net — filled $410.84 above its limit level: the bar gapped up through the limit and filled at the open. $1,232.53 of that trade's profit is gap, not bracket. Without it, trade #12 is +$704.81 and the weekly net is +$1,919.99, not +$3,152.52. The weekly "win" is still a win without the gap — but it is a much smaller one, and the reader of post #12 deserved that number in the first paragraph, not in a follow-up post. Consider this the correction.

Rules I now follow

  1. Count exits by reason before tuning anything. A bracket is three exits, not one. If you only look at the net, you will tune the exit that fires least.
  2. The stop is the strategy. When 65.5% of your exits are stops, the stop is the strategy — the entry and the limit are decorations on it. Tune the stop (wider? different basis?) before touching the target.
  3. A stop level is not a fill price. On daily bars, 18 of 38 stops filled past the level. Report the gap-through as its own line item, in dollars, before quoting the bracket's "risk".
  4. Watch for the exit that wins by accident. At 4×ATR the time exit became the best exit in the system without anyone designing it that way. An accidental best exit is a question, not a feature: it means the intended exit wasn't doing the job.
  5. The level is set by the previous bar's ATR, not the entry's. If you backtest a bracket by hand from entry prices, use the ATR of the bar before the exit bar — that's the level that actually fills. Using the entry bar's ATR left one of my early classifications 1.57 ATR away from the fill; the previous bar's ATR lands at 0.0000.

What this post gives you, and what it doesn't

This post gives you: the full exit-by-reason count for one real strategy on 4,089 daily bars (14 limit / 38 stop / 6 time), the same count at 3× and 4× limits, and the gap-through measured in dollars — $1,094.28 of extra stop loss on daily bars, and a $1,232.53 gap windfall inside post #12's headline weekly trade.

This post does not give you: a better bracket, or a verdict on RSI mean reversion. All three variants lose money; widening the target is not a fix, it is a re-labeling. It also doesn't test the obvious next question — what happens when the stop widens to 2×ATR, since the stop is the exit doing all the damage. That is the next post, and the multiplier will be chosen before I look at the result.

Next in the series: the stop side under the microscope — same script, stop widened to 2×ATR, counting whether the stop count finally moves.


How do you count your exits — by reason, or just by win and loss? I read every comment — the exit-split stories are what the next posts are built from.


This conversion work was done by Pine2Py, the tool I build for exactly this job: paste a Pine script, get PyneCore-flavored Python back, diagnostics included when something can't be translated. The runtime is the open-source PyneCore project, with a patched build we ship for the two constructs stock PyneCore doesn't handle — details are on the site. It's free to try — every account gets 3 conversions, no card — and Pro is $12/month if you end up converting a whole library. No return promises, ever: a translator moves your logic, it doesn't make it profitable.

Top comments (0)