Custom scripting
Write your own indicator in JavaScript
No proprietary language to learn. Define an indicator in plain JavaScript, and it plots through the same pipeline as the built-ins — running sandboxed, so it can never reach the network or freeze the chart.
- Plain JavaScript
- Web Worker
- ~2s budget
- No network
1const meta = {2 name: "RSI",3 placement: "pane",4 precision: 2,5 params: [6 { key: "length", label: "Length", type: "number",7 default: 14, min: 1, max: 500, step: 1 },8 ],9 figures: [10 { key: "rsi", title: "RSI", type: "line", color: "#34c06b", size: 2 },11 ],12};13 14function calc(candles, params, helpers) {15 const close = helpers.source(candles, "close");16 // Wilder RSI over the chosen length.17 return { rsi: helpers.rsi(close, params.length) };18}The shape
A meta block and a calc function
Declare what the indicator is, then compute one value per candle. Built-in helpers cover the common math, so a working study is a few lines.
const metaDeclares what the indicator is — its name, whether it draws in a pane or over the candles, the inputs it exposes, and the figures it plots.
function calcRuns on every update. It receives the candles and your params, and returns one value per candle for each figure you declared.
- Moving averages
- RSI
- ATR
- Standard deviation
- Linear regression
Sandbox model
Isolated by construction
The engine is built so a script is powerful on the chart and powerless off it. These are the guarantees, stated as specifics.
- Web Worker isolation
- Your code is compiled and run only inside a dedicated worker. The main thread never evaluates script source.
- No network access
- fetch, XMLHttpRequest, WebSocket, EventSource, and every other escape surface are removed before your code runs.
- ~2-second budget per run
- A run that exceeds it is terminated and a fresh worker is spawned. A script cannot hang the chart.
- Structured-clone-only I/O
- Everything crossing the boundary is shape-validated on both ends. Candles arrive as a packed array, oldest to newest.
- Strict result validation
- Output is checked twice: one finite number or null per candle, one array per figure. A bad result never reaches the chart.
- Failures stay contained
- A syntax error, thrown exception, or timeout surfaces as a legend error pill. Other indicators and live updates keep running.
Built for people who already write code
If you can write a function, you can write an indicator here. It is real JavaScript with real helpers, not a stripped-down dialect — so the logic in your head goes straight onto the chart, and what you learn carries over to everything else you build.
Open the editor
The Script Editor docks into any chart. Start from a built-in or a blank buffer.