Overview
This section is the code reference for indicator, definition and study scripts: every declaration, hook and ctx call, with examples you can paste into a builder's Code tab.
You do not need code to use Chartnaut. The Agent and each builder's agent write these scripts for you. Open these pages to write a script yourself, to read what an agent wrote, or to fix a lint error, a budget warning or a definition that emits nothing.
Map of this section
Section | Use it for |
|---|---|
Which script type to write, how a script is laid out, a first script of each type | |
What the engine promises about bars, warmup, seams and anchors, and the limits and errors you can hit | |
What every script shares: bar data, | |
Overlay or pane, series types, panes and scales, | |
Ten library indicators, from Volume to VWAP | |
| |
Bull bar, EMA cross, session opening-range break | |
| |
Event count, forward return, stop or target first hit | |
What the Agent and each builder's agent write, and the checks they run | |
FAQ, and pages that go from a symptom to its fix |
What definitions, studies and indicators are for is covered in the guides: How research works and How indicators work. This section covers how to write them.
Write scripts from a terminal or a coding agent
The same scripts run outside the app. The Chartnaut CLI and the Chartnaut API take the code, run it on Chartnaut's servers on the instrument, timeframe and range you ask for, and return what the script produced: an indicator's series, a definition's events or a study's results. You never receive raw candles. Both need Starter or above.
chartnaut new definition or-break
chartnaut validate definitions/or-break
chartnaut run definitions/or-break --on EURUSD --tf 5m --last 30d
chartnaut push definitions/or-break -m "first version"chartnaut run on a folder runs your local files and saves nothing. chartnaut push saves a new version, the same one you see in the app's builder, and chartnaut pull brings down a script you saved in the app. Saving and versions
Claude Code and Codex work well here. chartnaut init writes a guide the agent reads, and chartnaut docs <topic> prints any page in this section in the terminal. Working with Claude Code and Codex
How to read the API
Learn the shared pieces in Shared runtime: drawing,
indicators.declare, inputs, timeframe handles.Open the Indicator, Definition or Study section only for what that type adds: series outputs, events, or collect and publish.
To put a study's numbers on Charts, see Show studies on charts.
The pipeline
Indicator draws values on the chart, bar by bar (
onBar,ctx.plot).Definition marks a setup every time it happened in history (
events.declare,ctx.emitwith a required label).Study measures what followed those events (
onEvent,ctx.publish).Forward Insight shows a study's answer on Charts when the setup forms again. You create one with Attach to chart on a finished study run.

Common questions
Do I have to write code?
No. Start with Test your first trading idea or Build your own indicator, which use the Agent.
Which script type should I write?
See Choose your DSL.
Where are ctx.plot, ctx.range, ctx.hline and ctx.mark documented?
I want lines and histograms on the chart.
Read Series types, then Build a custom indicator.
I want to mark a setup in history.
Read Emit and labels, then Build a definition.
I want to measure what happens after a setup.
Read the Study API, then Build and run a study.
I want study numbers on my live chart.
See Show studies on charts and Forward Insights.
My script is slow or fails with a budget warning.
See Budgets and limits.
How do the agents write this code?
See the Agents overview.
