fix(engine): stop retro-arming explicit-zero-offset trails from the carried peak - #148
Merged
Conversation
…arried peak An EXPLICIT trail_offset=0 is TV's one-shot exit-at-activation trail: it fills AT its activation crossing, so it can never survive into a later bar in the armed state — an armed zero-offset trail is an executed one. The per-bar ExitTrailState reconstruction nevertheless derived "armed" from the carried post-entry extreme, so when a strategy re-issues strategy.exit each bar with trail_points derived from close (level_t = entry ± prevBarClose * perc, trail_offset = 0), an activation level refreshed from a NEWER close could drop under a peak set beneath an older, higher level: the stop retro-armed at that stale peak and the position exited at the next bar's open (or at the stale level on an against-direction segment) — an exit TradingView never prints. Scope the carried-best pre-arming away from explicit-zero-offset trails only. An OMITTED trail_offset keeps the carried arming even though it shares the exit-at-activation fill rule: TV treats its activation as durable order state measured against the position's running extreme — pinned by corpus bracket-exit-stop-limit-trail-same-bar-01 2025-08-30 08:45 (entry 4392.08, activation 4392.26, entry-bar high 4396.01, first live bar opens 4392.25 one tick BELOW the level, TV fills at that open, which only a carried armed state produces; the corpus stays byte-identical under this change). Offset>0 trails likewise keep the reconstruction. TV rule for the explicit-zero shape (fitted 219/219 + 147/147 clean trailing exits on the boztilkiserhan serhan1 WMA scalp / ADX tapes, both of which pass trail_offset=0 literally): level_t = entry ± prevBarClose * perc, live from the bar after entry, intrabar cross fills at the level, at the open when the bar opens past it. Discriminating tape: scalp 2025-04-09 — the engine exited at the 14:15 open 1475.99 off a 1501.03 peak under the refreshed 1500.98 level, while TV holds to 16:30 @1501.19 (entry + C[16:15]*1.5%, to the cent). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Gate
pr-gatePASS — engine corpus zero regressions, scraped entering excellent+strong >= leaving.Verdict:
/Users/haoliangwen/code/pineforge-lab/pr-gate-verdict.json🤖 Generated with Claude Code