Scripting

Scripting

Strategies and indicators in Vectaris are plain TypeScript scripts, written in the Editor module and run entirely in your browser against a small, purpose-built API — no imports, no build step, no server round-trip. This page covers the script types, the Editor that hosts them, the rules every script follows, and where each type actually executes.

Script types

  • Strategy — exports config, init(ctx), and onBar(bar, ctx) (or onTick(tick, ctx) in portfolio mode); places orders through ctx. See Strategies.
  • Indicator — exports config and calculate(data, params); plots on the chart and is callable from strategies by name. See Indicators.
  • Drawing tool — a third type slot exists in the Editor's New-script picker, but it's disabled today with a "Coming soon" label — there's no drawing-tool runtime yet. See Drawing tools.

The Editor module

Each Editor tab holds exactly one script — there's no file explorer inside the tab itself; the sidebar file manager is the tree, and it's also your library of saved strategies and indicators.

  • New script — pick a type (Strategy or Indicator; Drawing tool is disabled) and, optionally, a name; the Editor seeds that type's starter template into a fresh tab.
  • Name field — the header carries an editable name field; it's what the script saves as.
  • Save / Save As — Save compiles the script first and stays disabled while there are compile errors; Save As always adds a new copy to the library rather than overwriting.
  • Built-ins are read-only — opening a built-in strategy locks its code surface, shows a "BUILT-IN · read-only" badge next to the type badge, and replaces Save with a single Save a copy button. The name field stays editable so you can name the copy; saving adds a new, fully editable script to your library and the tab unlocks.

Rules every script shares

  • TypeScript. Scripts are TypeScript, stripped down to JavaScript to run — there's no separate type-checking step in that path.
  • No import. Everything a script needs comes through the ambient API instead — ctx for strategies, the data/params arguments for indicators. This is a portability guard, not a security boundary: a script can still reach globalThis, fetch, and anything else the browser exposes. Real isolation comes from where scripts execute, not from the import ban.
  • Diagnostics are two-tier. Red errors come from compiling the script (syntax errors, or the no-import rule) and gate Save. Yellow errors come from checking the script's types against its ambient API and are informational.

Where scripts run

  • Backtests run locally in a browser worker pool, at no cost.
  • Charts render indicator scripts through a generic plot adapter — your calculate() output drives the same line/histogram/dots drawing primitives every built-in indicator uses.
  • Live deployments are browser-attended: they run in your open tab, not on a server. See Paper and live.