Skip to content

Suppress the close leg of a fill-price-declined reversal#91

Merged
luisleo526 merged 1 commit into
mainfrom
fix/declined-reversal-close-leg
Jul 10, 2026
Merged

Suppress the close leg of a fill-price-declined reversal#91
luisleo526 merged 1 commit into
mainfrom
fix/declined-reversal-close-leg

Conversation

@luisleo526

Copy link
Copy Markdown
Collaborator

What

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), 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 (the calc_on_order_fills kernel 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_all and partial closes keep current behavior (characterization-frozen).

Evidence

  • 0-mismatch predictive rule across 208 traced reversal bars (55 declines / 153 admits, both directions); every traced decline gaps exactly +1 mintick over the sizing close.
  • TV fired the paired close once in ~960 decline events across ten strategies (budgeted as a documented residual).
  • Creation-order binding pinned by a strategy whose sell leg creates the close BEFORE the entry — TV fires that close 115/115; it remains unsuppressed.

Gates (author + independent fresh-context R7, both green)

  • REDs by stash-cycle: 27/12 pre-fix → 39/39 post-fix (suppression rows fail pre-fix; characterization rows pass both sides).
  • Full ctest 89/89; corpus 252/252 — 240 excellent / 11 strong / 1 anomaly, zero movement, cap/reversal/GB2 probe families byte-neutral; ledger re-credit proven by a follow-up-close fixture.
  • Private validation sweeps: targeted 13 UP / 0 DOWN, full 412 +5 more UP / 0 DOWN (18 total, 11 straight to excellent), error inventory stable; all down-sentinels held.

🤖 Generated with Claude Code

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>
@luisleo526 luisleo526 merged commit bc49fc8 into main Jul 10, 2026
5 checks passed
@luisleo526 luisleo526 deleted the fix/declined-reversal-close-leg branch July 10, 2026 21:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant