Skip to content

Let a priced entry reverse a same-bar opposite market fill#96

Merged
luisleo526 merged 1 commit into
mainfrom
fix/dual-entry-placement-sizing
Jul 11, 2026
Merged

Let a priced entry reverse a same-bar opposite market fill#96
luisleo526 merged 1 commit into
mainfrom
fix/dual-entry-placement-sizing

Conversation

@luisleo526

Copy link
Copy Markdown
Collaborator

What

Two opposite strategy.entry calls on one bar from flat — market first, priced (stop) second — previously resolved with the priced entry's fill taking the close-only-opposite gate: it closed the market position and was dropped, engine flat where TV holds the second entry. A committed clean-room probe pins TV running no arbitration: both entries execute; the second call sizes own + pending same-bar opposite MARKET qty — exactly what the ordinary full-reversal path produces from flat.

Fix: one placement-time flag (priced entry created flat with an earlier same-bar opposite MARKET sibling by creation order) scopes the close-only-opposite gate out of market-first cells. Stop siblings don't set it; placement-rejected entries never queue; deferred-flip carries never match — the gate's original semantics survive (deferred-flip suite green).

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

  • REDs by stash-cycle: 23/3 pre-fix → 26/26 post; full ctest 94/94.
  • Corpus 252/252 — 240/11/1 zero movement; R7 additionally attributed the long-standing 5-CSV corpus working-tree drift to stale pre-Suppress the close leg of a fill-price-declined reversal #91 committed baselines (no-fix vs fixed engines byte-identical on all five) and left the submodule clean.
  • Probe: engine trade count 7,429 == TV exactly (matched 78.9%; residual = characterization-frozen unpinned cells + one documented decomposition difference).
  • The motivating strategy is byte-identical (md5-proven, both engines); private sweeps targeted 9/9 + full 412 both 0 up / 0 down.

🤖 Generated with Claude Code

When two opposite strategy.entry calls fire on the same bar from flat —
a market entry first, a priced (stop) entry second — the priced entry's
fill previously took the close-only-opposite gate: it closed the
market entry's position and was itself dropped, leaving the engine flat
where TradingView holds the second entry's position. A clean-room probe
(committed with its TV export) pins TV running no arbitration: both
entries execute, and the second call's size covers its own quantity
plus the pending same-bar opposite market quantity — which the ordinary
full-reversal path reproduces exactly, since the closed position IS the
market entry's quantity when placed from flat.

Fix: a placement-time pending-order flag (priced entry created flat
with an earlier same-bar opposite MARKET sibling) scopes the
close-only-opposite gate out of market-first cells. Pending stop
siblings do not set the flag (stop-vs-stop single-close preserved);
placement-rejected entries never reach the queue; deferred-flip carries
never match (created with a position open), so the gate's original
semantics survive untouched.

The probe's engine trade count converges to exactly TV's 7,429; the
strategy that motivated the class is byte-identical (its dual bars ride
the placement-rejection path). Out of pinned scope, characterization-
frozen: stop-first cells that never ran in the probe, pyramiding>0, and
TV's buy-first intra-open ordering (net position parity reproduced;
trade decomposition of one cell differs, documented).

Corpus 240/11/1 zero movement; full private sweep 0 up / 0 down.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@luisleo526 luisleo526 merged commit b6e4e35 into main Jul 11, 2026
5 checks passed
@luisleo526 luisleo526 deleted the fix/dual-entry-placement-sizing branch July 11, 2026 13:31
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