EngineOrders & Positions

Getting started

Follow one entry and one exit using the tested SJS crossover example.

Use the complete SJS crossover source for this walkthrough. It buys one unit on an upward crossing and requests a close on a downward crossing. The source and its behavior are covered by the documentation example tests.

Prepare the execution environment

Use a fresh, single-instrument historical experiment. Leave other order-producing models, Pine, and L3 disabled for this first walkthrough. Choose available one-minute bars, sufficient capital, and zero fill delay so you can inspect the simplest simulated execution sequence.

The example is long-only, accepts at most one returned position, and waits while any order exists. Its quantity is explicitly set to one in the source; changing only the app's default quantity does not change that literal.

Follow the reference sequence

At increasing one-minute timestamps, closes 100, 100, 100, 103, 99 give this sequence:

ObservationStrategy stateExecution expectation
First two closesWindow warming upNo request
Third close: 100Initial relationship establishedNo request
Fourth close: 103Upward crossoverRequest BUY quantity 1 when flat and without pending orders
Fifth close: 99Downward crossoverRequest close only if the long exists and no order is pending

These prices are a deterministic reference fixture, not a prediction that your selected market period contains that sequence. With real historical data, find the corresponding crossover conditions and inspect their timestamps.

Inspect each outcome

Read the sjs-crossover attempt log, then the reported orders, positions, and trades. In the memory simulator, an eligible zero-delay market request can fill during submission. A successful call therefore does not guarantee you will later see a pending order row.

If the order remains pending, identify its delay, price, quote, capital, or runtime constraint before modifying the signal. An EXIT signal does not close a position that has not yet opened.

Try a delayed fill

Repeat with a nonzero fill delay and the same input. The strategy waits when an order is pending, including at an exit crossover. Its timestamp and crossover state have already advanced, so it does not retry that consumed signal automatically.

This demonstrates why signal generation and order management need separate state. The fixture tests verify request decisions and guards; they do not substitute for inspecting your run's actual fills.

Continue with placing orders.

On this page