Documentation

2. Authoring Language & Syntax

Created
Jun 5, 2026
Updated
Jun 5, 2026

Both custom indicators and strategies use one authoring engine, so the accepted language is identical. This page describes what you can write and what is rejected.

TypeScript and JavaScript

You can write TypeScript or JavaScript. Types are stripped, not type-checked — annotations are allowed and erased at compile time, so they document intent but do not validate it. ESM import/export syntax is recognized, and export default is the expected way to export your module.

Module shape

export default {
  name: "My Study",      // optional label
  init(ctx) { /* … */ }, // optional, runs once
  next(ctx) { /* … */ }  // runs once per bar
};

A bare top-level return { … } is also accepted for back-compat.

Strict by default

The engine runs in strict mode and rejects known footguns up front with a clear error, rather than compiling and misbehaving silently. The following are not allowed:

RejectedWhy
async init/nextThe per-bar engine is synchronous; async functions never settle in time.
Returning a Promise from nextA result would be silently dropped.
import of values (and dynamic import())Authored modules must be self-contained. (import type … is fine — it is erased.)
TypeScript namespace / module blocksThey compile but are erased, then throw at runtime.
DecoratorsNot supported.

Sandboxing

Authored code cannot reach the browser environment. A long list of globals — including window, document, fetch, XMLHttpRequest, WebSocket, localStorage, process, require, setTimeout, setInterval, and Worker — is shadowed (passed in as undefined), so your code is a pure, self-contained computation. Strategies additionally run inside a worker that can be hard-terminated.

Errors

  • A compile-time problem (syntax error, banned construct, or bad module shape) is reported before the run, with a message and — where possible — a line number.
  • A runtime error inside next() is contained: for an indicator it nulls just that bar and continues; it never aborts the whole series.

Next steps

Put the language to work in a custom indicator.

Next: Writing Custom Indicators