Skip to content

Getting Started

Tea Script files for user-authored indicators live under custom/**/*.ts in the indicator library repo. Built-in indicators live under builtin/*.ts and are read-only from the authoring surface.

indicator('Simple Moving Average');
period = input.int(20);
value = ta.sma(close, period);
output('value', value);
plot(value, 'SMA');

This script declares one integer input, computes a moving average over the bound chart close series, persists the value as an output, and plots the same series on the chart.

  • Start with one declaration: indicator("Name") or strategy("Name").
  • Use assignment statements for intermediate values.
  • Emit at least one value with output(...) or plot(...).
  • Use input.int(...) or input.float(...) for user-configurable parameters.
  • Use the capability reference for the accepted function and effect surface.

The sandbox validator is generated from TSGraph-owned authoring assets. It accepts a script path and prints JSON diagnostics:

Terminal window
node validate-tea-script.mjs custom/simple-moving-average.ts

Inside the OpenChart repo, the same validation contract is checked by the authoring asset generator and merge gate:

Terminal window
bun run check:authoring
bun run --cwd packages/tsgraph check:authoring