Skip to content

Known issue: with calc_on_order_fills, an exit that the script calls on every execution can fill more than once for the same entry #854

Open

Description

@luisleo526

Affected releases: 1.2.0 through 1.12.0. Earlier releases have not been checked.

Which scripts: a strategy with calc_on_order_fills = true that calls, on every execution while the position is open, a strategy.exit for an entry with a fixed qty smaller than the position, a limit and a stop, and another strategy.exit of the same entry whose quantity is a share of the current position. In our tests, a script with only the first of those exits (no second exit sized from the position) was not affected. Whether a script without calc_on_order_fills, or exits with only a limit or only a stop, are affected has not been established yet.

What the engine does: after that exit has filled once for the entry, the engine arms the same exit again for the entry's remaining quantity when the script calls it again. The exit can then fill a second time (on a following bar, when the price is still beyond its limit) and a third time (at its stop). A second strategy.exit of the same entry that is sized from the current position then closes less than it should, and a final strategy.close_all may find nothing left to close.

What TradingView does: it fills that exit once for the entry. The remaining quantity stays open until another order closes it.

Effect on results: the entry and the total quantity closed are the same, but the position is closed earlier and in different pieces. The list of trades has extra rows for that exit id, later exits are smaller, and a closing row that TradingView books can be missing. Net profit, the number of trades and every per-trade statistic can differ from TradingView's.

How to recognise it: in the list of trades, the same exit id closes more than one trade for one entry, although the script gives that exit one quantity.

Status: a fix is in progress; this entry will name the release that carries it.

We will update this entry as the affected scope is confirmed.

🤖 Generated with Claude Code

Activity

  1. luisleo526 commented on Nov 13, 2026

    @luisleo526
    CollaboratorAuthor

    Status 2026-11-13: the fix is in progress; its candidate is due 2026-11-14 and it is targeted for 1.13.0 (planned 2026-11-15). If it is not ready in time, 1.13.0 ships without it and it follows in the next patch release; we post that here the same day.

    🤖 Generated with Claude Code

  2. luisleo526 commented on Nov 14, 2026

    @luisleo526
    CollaboratorAuthor

    Status 2026-11-14: work on the fix is under way, but its date is not established yet. We will post the date here by 2026-11-14 18:00 (UTC+8).

  3. luisleo526 commented on Nov 14, 2026

    @luisleo526
    CollaboratorAuthor

    Status 2026-11-14 17:00 (UTC+8): a fix is written and its focused checks pass; it is in final review now. It is planned for the 1.13.0 release. We will post the next update here by 2026-11-15 12:00 (UTC+8).

  4. luisleo526 commented on Nov 15, 2026

    @luisleo526
    CollaboratorAuthor

    Status update (2026-11-15, UTC+8), as promised for today 12:00:

    • Cause: the late exit you reported (one trade closing about 4 days after it should on XAUUSD 15m) is a real engine defect, and we reproduced it.
    • Fix: written, and in final review. The review found that it interacts with a second fix in the same exit-handling code (Partial exits: three shapes where a partial strategy.exit gets no quantity, or one order for several same-ID entries (related to #694) #810). The two have to follow one rule so that, once combined, they cannot reintroduce the late exit. We measured that interaction this morning, and the next version of the fix resolves it.
    • What's left: that next version, then the full test suite, the comparison runs against TradingView-matched results, a final review and one complete verification build.
    • Delay: an outage on our side has paused the work since about 10:10 today.
    • Release: we are aiming at 1.13.0. If it misses 1.13.0, we will say so here the same day.

    Next update here by 2026-11-15 20:00 (UTC+8), or sooner when the fix merges.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions