EngineSJS

SJS

Write the main algorithm in JavaScript, from market signals to entries, exits, and session state.

SJS is where you write the main trading algorithm. Your app function receives the current market-data frame and session context, then decides what to observe, remember, or request. It can calculate signals, use injected helpers, inspect positions and orders, and manage entries and exits.

You can build a complete SJS strategy without Pine or L3. Pine can supply additional calculations and signals. L3 is an optional advanced layer for higher-level coordination and execution checks.

Start with a complete strategy

The getting-started guide builds a long-only moving-average crossover using three observed closes. It includes warmup, timestamp validation, repeat protection, pending-order checks, explicit execution sources, and outcome logging.

Every subsequent guide explains a part of that same strategy rather than requiring a different runtime setup.

GuideWhat you will learn
Getting startedPaste and run a complete standalone strategy
LifecycleUnderstand frames, async work, and skip controls
ContextFind the session APIs and injected helpers
Market dataHandle timestamps, missing input, and signal freshness
Indicators and algorithmsCalculate locally or consume engine capabilities
StateOwn memory and avoid repeated requests
Orders and positionsSubmit entries and closes and interpret results
DebuggingExplain missing trades and failed requests
ExamplesWalk through fixed inputs and useful variations
Working with L3Add optional oversight to an existing SJS strategy

The boundary with L3

SJS receives an L2 frame scope. It does not currently receive modules.policies. An enabled L3 script can check SJS execution requests through its own intent export; SJS continues to call the normal session APIs.

Start with SJS, make the strategy's behavior explainable in a historical test, then add L3 only when you need that additional layer. See the engine overview for the full flow.

On this page