EngineBacktesting

Warmup and readiness

Give calculations enough observations and separate strategy warmup from live-session preloading.

Warmup can mean two different things: your calculation accumulating enough observations, or a live session fetching earlier data before normal processing. Historical memory runs do not automatically inherit the live preloading window.

Historical memory sessions

The memory and polymarket-memory session types resolve external warmup to zero. The supplied historical window is the input for the run. If a calculation needs earlier observations, include them in the selected data window or use its explicitly supported history-loading behavior.

The SJS crossover uses only its own observed closes. Two valid timestamps warm up the sample window; the third establishes an initial relation; a later observation can produce a crossover. Changing the start date can change its first eligible decision even when the later bars are identical.

Gaps can restart the strategy

The tutorial resets its local window after a gap greater than two minutes. This is a strategy rule, not an engine-wide indicator rule. A higher input interval or skipped session period can therefore trigger another warmup.

Configured algorithms and calculators have their own readiness contracts. A model instance existing in context.algos does not prove its snapshot is ready, and a calculator returning a value does not prove the dataset contains the intended amount of history.

Leading history is not automatically excluded

Extending a backtest's start date provides more history, but the historical run can also trade during that added period once the strategy permits it. There is no universal “these first bars are initialization only” assumption in the example.

If you need a later evaluation boundary, continue updating the strategy's calculations during the leading data and explicitly gate when entry decisions may execute. Define whether any positions may cross the evaluation boundary and how you will compare results. Keep those rules with the source revision.

Live preloading differs

Pine live sessions default to a one-hour external warmup unless configuration overrides it. Generic warmup feeds observations through the session with inWarmup set, suppressing execution and normal update publication. Memory historical sessions deliberately skip that external preload.

A live session can therefore start with different indicator state and observation granularity from a short backtest. Compare their actual initial data and readiness rather than assuming the same plotted start time gives the same state.

AI calls during replay

Real L3 provider calls are disabled during backtesting and historical warmup. Agent Lab's AI authoring conversation is separate from provider calls made inside strategy source. Use deterministic policies or supported fake-provider responses to exercise decision logic during replay.

Continue with Comparing runs and Limitations.

On this page