Overview
This page tells you which kind of script to write before you open a builder's Code tab.
Chartnaut has three script types. An indicator draws values on the chart. A definition marks a setup every time it happened in history. A study measures what usually followed those marks. A fourth step, the Forward Insight, puts a study's answer on Charts; you create it with Attach to chart, not by writing a script.
Decision table
Goal | Script | Key APIs | Written by |
|---|---|---|---|
Lines, histograms, boxes or levels on the chart | Indicator |
| The indicator builder's agent, or the Agent |
Mark a setup in history | Definition, |
| The definition builder's agent, or the Agent |
Measure what followed each event | Study |
| The study builder's agent, or the Agent |
Show a study's answer on Charts | Forward Insight | Attach to chart on a finished run | A dedicated agent inside the attach wizard |
A definition can also be kind: "indicator": a multi-file script that paints but emits no events.
How they connect
Indicator (draws values)
↓ can be a dependency of
Definition (emits events)
↓ run over history → events
Study (measures and publishes results)
↓ Attach to chart →
Forward Insight (the answer on Charts, on the bar where the setup forms)Studies never call ctx.emit. They read the events of the definitions they declare with flows.declare.
Builder or Code tab
Job | In the app | Reference |
|---|---|---|
Build an indicator | Tools → Indicators, then New | |
Build a definition | Tools → Definitions, then New | |
Build a study | The definition's Studies tab, then New study | |
Put a study's answer on Charts | Attach to chart on the study's results |
In the indicator and definition builders, Build it yourself under the suggestions opens an empty script. In the study builder, Show Code opens the script.
To build without code, start from Test your first trading idea or Build your own indicator. Both use the Agent.
Most APIs (drawing, inputs, indicators.declare, timeframe handles, sessions, budgets) are documented once under Shared runtime. The Indicator, Definition and Study sections cover what each type adds. Script anatomy shows the layout every script follows.
