FINTERM · docsOpen terminal
Indicator scripting

Scripting reference

Function signature, candle schema, return value contract, color palette. The full surface area.

Function signature

function indicator(candles, OHLC) {
  // your code here
  return /* see return shapes below */;
}

You don't write this declaration — the sandbox wraps your code body in a function that takes these arguments. Just use `candles` directly.

candles

Array of OHLC bars in oldest-first order. Each entry has the shape:

type OHLC = {
  time:   number;        // unix seconds
  open:   number;
  high:   number;
  low:    number;
  close:  number;
  volume?: number;       // present for binance / bitmex; may be missing for others
};

Length depends on what the chart has fetched plus what's streamed in since — typically a few hundred to a few thousand. The latest bar is `candles[candles.length - 1]` and updates in place as new ticks arrive.

OHLC argument

Currently undefined — the slot is reserved for a future helpers object. Don't depend on it.

Return shapes

Return any of these. The chart normalises whichever you pick into { outputs, series }.

numberTreated as a single named output, name='value'. No series drawn.
{ name, value, color? }Single labelled scalar. Renders in the legend chip strip.
Array<{ name, value, color? }>Multiple scalars. One chip each.
{ outputs: [...], series: [...] }Combined: scalars in chips + per-bar series as polylines on the chart.
null / undefinedNo output. Useful as 'not enough data yet' (e.g. inside the warmup window of a moving average).

Series shape

type Series = {
  name:   string;          // legend label
  values: (number | NaN)[]; // one entry per candle in the FULL history
  color?: string;          // semantic alias OR raw CSS color
};
warnvalues.length should equal candles.length. Use NaN (or null) for warmup positions where the indicator can't be computed yet — the renderer skips those points instead of drawing a line through zero.

Color palette

Series colors accept either a semantic alias (resolved against the active theme) or a raw CSS color string.

'azure'var(--azure) — the cool accent (typically blue).
'up'var(--up) — green / positive.
'down'var(--down) — red / negative.
'warn'var(--warn) — amber / caution.
'ink'var(--ink-hi) — high-contrast text color, default.
'#3b82c4' / 'rgb(...)'Any valid CSS color string passes straight through to the canvas stroke style.