reference

Overview

Definitions teach Chartnaut when a setup appears in the market so you can Collect every historical match and later study what usually happens next.

In the product UI the noun is always Definition; in Code the API word is flow. Drawing and shared helpers live under Shared runtime. This section covers events, required emit labels, imports, and multi-file packages.

Covered in Shared runtime

Topic

Page

outputs.declare + plot/mark/hline/range/note

Drawing on the chart

indicators.declare

Declaring indicator dependencies

Inputs / layout / accum / bar fields

Shared runtime

Unique to definitions

Page

Covers

Definition meta

kind: "flow", slug, runOn

Events and snapshots

events.declare, snapshots.declare

Emit and labels

Required label on ctx.emit

Definition onBar

Emit + session + windows

Multi-file packages and imports

imports.use + multi-file ESM

Minimal flow

meta({ name: "Tick Signal", kind: "flow", slug: "tick-signal" });
events.declare({
  id: "tick",
  intent: "alert",
  payload: { reason: { type: "string", description: "Why this fired" } },
  paint: "pin",
});
outputs.declare({ id: "close_line", kind: "line", name: "Close" });

export function onBar(ctx) {
  ctx.plot("close_line", ctx.close);
  if (ctx.close > ctx.open) {
    ctx.emit("tick", { reason: "bullish_bar" }, {
      label: "Bull bar",
      price: ctx.close,
    });
  }
}

Next

  1. Shared runtime

  2. Emit and labels

  3. What is a definition