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.
| Guide | What you will learn |
|---|---|
| Getting started | Paste and run a complete standalone strategy |
| Lifecycle | Understand frames, async work, and skip controls |
| Context | Find the session APIs and injected helpers |
| Market data | Handle timestamps, missing input, and signal freshness |
| Indicators and algorithms | Calculate locally or consume engine capabilities |
| State | Own memory and avoid repeated requests |
| Orders and positions | Submit entries and closes and interpret results |
| Debugging | Explain missing trades and failed requests |
| Examples | Walk through fixed inputs and useful variations |
| Working with L3 | Add 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.