EngineSQL-Inspired Rules / SQX

Actions

Understand target updates and branch controls before a rule can request execution.

SQX actions run after a condition matches. Most SET examples update an existing primitive; they are not direct calls to context.placeOrder.

Declare the target first

IF order type="limit" action="buy" size=1 limitPrice=50 transmit=false
TICK price > 50 THEN order SET note="limit candidate", transmit=false

The declaration creates the configured order primitive. The rule updates recognized properties on an eligible instance. A target name without a configured instance does not create one, and unknown property names are not made valid by the parser.

For this primitive, use size for quantity and limitPrice for a limit price. quantity, price, and capital are not substitutes for those writable primitive properties. SJS order requests have a different shape.

transmit=true permits the primitive to request placement when its callback runs. It does not place an order at parse time, guarantee acceptance or fill, or provide pending-order and position guards.

Targets and ordering

L2 rules run in configured order before their applicable L1 callbacks. More than one rule may update the same property, so a later matching update can replace an earlier one.

After the normal tick or position branch, declared parameters for that branch are restored. Declare the baseline values you depend on; do not rely on every undeclared property or custom state being reset.

FINAL actions

ActionCurrent effect
FINAL skipSkip later ordinary L2 work in the current branch; L1 can still run
FINAL skipallSkip later ordinary L2 and L1 work in the current branch
FINAL stopCall the session stop method; this is not an automatic flatten guarantee
FINAL closeIn POS, request closing the matching current position; in TICK, logs that close is unavailable

Session models marked to run through skip gates can still update. Skip flags also affect later native Pine execution. None of these actions undoes SJS requests already made earlier in the frame.

The add and reduce names route through target updates in this shared L2 action layer. Do not assume they independently size and send an add/reduction order. An unrecognized FINAL name can parse but fail during execution.

Position actions

POS pnlTicks > 5 THEN FINAL close

This is an execution example, not part of the non-transmitting getting-started source. It requests a close when the position branch runs and the calculated price difference exceeds five. Execution gates and the selected adapter still determine the result.

Continue with working with SJS.

On this page