Skip to content

Order functions accept unknown named arguments, including the removed when, and drop them #286

Closed

Description

@letiep97

Summary

The order functions accept any named argument and drop it without a message. Pine v6 removed the when parameter, and TradingView rejects it in v6, but a v6 script that still passes it translates: the condition disappears and the order is placed on every bar. Other built-ins reject unknown names, for example ta.sma(close, 10, when = true) fails with ta.sma has no parameter 'when'.

Versions

pineforge-codegen 1.9.1 and 1.9.0 (1.6.1 too). The run below used pineforge-engine v1.9.0 (ec44968), Apple clang, macOS arm64. The argument is dropped in the front end, so it should not depend on the platform.

Repro

//@version=6
strategy('repro')
strategy.entry('L', strategy.long, when = bar_index % 20 == 0)
strategy.close('L', when = bar_index % 20 == 10)

Generated:

strategy_entry(std::string("L"), true, na<double>(), na<double>(), na<double>(), "");
strategy_close(std::string("L"), "", na<double>(), na<double>(), false, 17179869199ULL);

On a daily series from 2020-01-01 to 2024-01-01 (1,461 bars) this gives 673 trades; the conditions allow about 73.

The same happens with:

  • when = false on strategy.order, strategy.exit, strategy.cancel and strategy.cancel_all: all translate, with no condition left.
  • A name that never existed: strategy.entry('L', strategy.long, bogus = true) translates the same way.

Expected

Order functions reject unknown named arguments, as the other built-ins do. For when, a message saying that v6 removed it would help scripts migrated from v5.

Activity

  1. luisleo526 commented on Nov 1, 2026

    @luisleo526
    Contributor

    Thank you for the detailed report. We are checking each case against TradingView's behaviour and our source, and will post a result for each case in this issue by the end of 2026-11-03 (UTC). If a case needs longer, we will say so here with the reason.

  2. luisleo526 commented on Nov 3, 2026

    @luisleo526
    Contributor

    Thank you for the report. This is the result for each case on the released pineforge-codegen 1.10.0. The fix is planned for the next release (1.10.1), as the 1.10.0 release notes list for this issue.

    Case Result on 1.10.0 Matches TradingView?
    when = ... on strategy.entry and strategy.close (your repro) Translates; the argument is dropped, so the order is placed on every bar No: TradingView v6 rejects when
    when = false on strategy.order, strategy.exit, strategy.cancel, strategy.cancel_all Translate; the argument is dropped No: TradingView v6 rejects when
    An argument name that never existed (bogus = true on strategy.entry) Translates; the argument is dropped No: TradingView rejects an unknown argument name

    All three are defects, not intended behaviour: the order functions accept any named argument. Other built-ins already reject unknown names (as with your ta.sma(close, 10, when = true) control), and the order functions are to do the same, with a message for when that says v6 removed it. The fix is planned for the next release (1.10.1); the issue stays open until it is released.

  3. luisleo526 commented on Nov 6, 2026

    @luisleo526
    Contributor

    The fix, merged in #327 (commit 08261a2), is on main and not yet released;
    it ships in the next release and closes then. We ran your reporter script with
    when on strategy.entry and strategy.close; both calls now produce located
    PF-E2027 unknown-keyword diagnostics instead of silently dropping their
    conditions, matching TradingView's rejection. The other when and unknown-name
    forms in the issue are covered by the public regression tests but were not part
    of this reporter run. The current message is the generic “unknown keyword
    argument 'when'”; the promised v6-specific wording is not on main yet.

  4. luisleo526 commented on Nov 8, 2026

    @luisleo526
    Contributor

    Update: the argument rejection is fixed on main; the diagnostic wording remains generic.

    The results below were checked on 2026-11-06 on main after #327 (08261a24) landed, as reported in our earlier comment. They were not re-run today; that comment identifies the fix commit but does not record the exact tested main commit.

    Case Result on main Change Matches TradingView?
    when = ... on strategy.entry and strategy.close (your repro) Both calls produce located PF-E2027 unknown-keyword diagnostics instead of dropping the condition #327 (08261a24) Yes: both are rejected, as in the issue
    when = false on strategy.order, strategy.exit, strategy.cancel, strategy.cancel_all Covered by the reported regression tests for unknown keywords; not part of the reporter-script check #327 (08261a24) Rejection is covered; no separate reporter-script measurement
    An argument name that never existed (bogus = true on strategy.entry) Covered by the reported regression tests for unknown keywords; not part of the reporter-script check #327 (08261a24) Rejection is covered; no separate reporter-script measurement

    The message remains “unknown keyword argument 'when'”. Our earlier promise of wording that specifically explains its removal in v6 is not implemented on main; this update confirms the rejection, without claiming that wording change.

    This is fixed on main and ships in 1.11.0, whose publish target is 2026-11-10. This issue will be closed when that release is published.

  5. luisleo526 commented on Nov 9, 2026

    @luisleo526
    Contributor

    Fixed in v1.11.0: order functions now refuse unknown named arguments, and the removed when argument has its own error message (commit 08261a2 and #355). Closing.

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions