Suppress the close leg of a fill-price-declined reversal#91
Merged
Conversation
Pine reversal idiom: strategy.entry(opposite) then strategy.close(current) on the same signal. When the percent-of-equity admission gate declines the reversal entry at fill (unaffordable at the slipped fill price), TradingView refuses the reversal atomically — neither leg fires and the position is held. The engine declined the entry but still filled the co-queued close, going flat where TV holds, then re-entering on a later signal TV no-ops. At the reversal-decline site (and only there — the same-direction, gap-reject, and fixed-sizing role-change decline sites are excluded), matching pending close legs are flagged: same-direction full closes with an explicit target, created on the declined entry's signal bar after it. Flagged orders are removed by classify_order_eligibility and an apply-time guard (the calc_on_order_fills kernel pre-classifies its candidate set, so a mid-segment flag needs the apply-time check). The close's call-time id-ledger debit is re-credited exactly once so later closes on the held position still fire; close_all and partial closes keep current behavior. Evidence: 0-mismatch predictive rule across 208 traced reversal bars (55 declines / 153 admits, both directions); every traced decline gaps exactly one mintick above the sizing close; TV fired the paired close once in ~960 decline events across ten strategies. Validation corpus: 252/252, 240 excellent / 11 strong / 1 anomaly — zero movement, cap and reversal probe families byte-neutral. Private parity sweep: 18 tiers up / 0 down (11 straight to excellent). 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.
What
Pine reversal idiom:
strategy.entry(opposite)thenstrategy.close(current)on the same signal. When the percent-of-equity admission gate declines the reversal entry at fill (unaffordable at the slipped fill price), TV refuses the reversal atomically — neither leg fires, the position is held. The engine declined the entry but still filled the co-queued close: flat where TV holds, then re-entry on a later signal TV no-ops. Ten all-in strategies carried ~960 such extra round-trips.Fix, scoped to the reversal-decline site only (same-direction, gap-reject, and fixed-sizing role-change decline sites explicitly excluded): flag matching pending close legs (same-direction FULL closes with explicit target, created on the declined entry's signal bar after it), remove them via
classify_order_eligibility+ an apply-time guard (thecalc_on_order_fillskernel pre-classifies its candidate set, so mid-segment flags need the apply-time check), and re-credit the close's call-time id-ledger debit exactly once so later closes on the held position still fire.close_alland partial closes keep current behavior (characterization-frozen).Evidence
Gates (author + independent fresh-context R7, both green)
🤖 Generated with Claude Code