FINTERM · docsOpen terminal
Indicator scripting

How indicators work

The chart sandboxes your code in a Web Worker, runs it against the candle history, and plots the result.

Click the ƒ Indicators button on any chart to open the presets menu. Picking a preset assigns its code to the chart's indicatorCode field and opens a TextEditor window bound to that field — you edit JS, the chart re-runs your function on every tick (throttled to ~5 Hz), and the returned series draws as polylines aligned bar-by-bar with the candles.

The pipeline

  1. You write a JS function body. The sandbox wraps it as `new Function('candles', 'OHLC', code)`.
  2. Each tick (Binance WebSocket message), the chart pushes the candles array into a Web Worker.
  3. The worker calls your function and posts the return value back.
  4. The chart normalises the return value into { outputs, series } and hands the series to the renderer.
  5. The renderer draws each series as a polyline; outputs render as labelled scalars in the chart's legend chip strip.

Sandbox guarantees

  • Your code runs in a Web Worker — no access to the page DOM, window, document, fetch, or the user's data.
  • 1-second timeout per call. If your function loops forever the chart simply stops getting new outputs; nothing else breaks.
  • Errors are caught and surfaced as a toast in the editor — they don't crash the chart.
  • No persistent state across calls. Treat each invocation as pure: same inputs, same outputs.
tipThe same sandbox runs the Backtester. If you've prototyped an indicator, the same `candles` array and the same return shape work in a backtest with a different `kind`. See Backtester docs.