ChartnautDocs

Indicator authoring agent

The indicator builder's agent writes and edits one indicator script: inputs, outputs, dependencies, layers and onBar. Its edits apply straight to the code, and the chart beside the chat reloads with each one.

Ask it for values drawn on the chart. A setup marked in history is a definition, and numbers on a Forward Insight come from a study.

How an edit lands

Every edit saves. Code that does not compile is saved too: the chart keeps showing the last version that did, and the agent reads the error back from the same result and fixes it with another edit. Saving is not publishing: the indicator stays private until you change its visibility.

The only thing it asks you first is using another indicator from the library. That shows as an Indicator proposal card, such as Add VWAP?, with Approve and Reject.

Its loop on every change

  1. Read the current script with get_indicator_state.

  2. Decide the contract before writing: inputs, outputs, which pane each output lands on, the ctx.accum slots, any timeframe handles.

  3. Save with edit_indicator_code (a small exact replacement) or write_indicator_code (the whole file).

  4. Lint with lint_indicator and typecheck with typecheck_indicator. Both read the saved script.

  5. Dry-run with dry_run_indicator: the production engine over real bars from a preset market, dependencies included.

  6. For a script with output.layer, grade the paint with bench_layer.

  7. Check the builder's chart with wait_for_preview, then inspect_preview, and read ctx.log output with get_indicator_logs.

A clean typecheck is not verification. It cannot tell a wrong number or a level in the wrong place; only the chart can.

Tools

Tool

Runs in

Does

get_indicator_state

Server

The saved script, manifest, defaults and latest version

write_indicator_code / edit_indicator_code

Browser

Save a whole file or an exact replacement; returns compile, typecheck and bench results

lint_indicator

Browser

Compiles the saved script in the chart's sandbox and lists every lint error and warning

typecheck_indicator / read_indicator_dsl

Browser

Typechecks against the DSL's real declarations; reads those declarations

dry_run_indicator

Server

Runs the saved script over a preset market. Returns outputs, never_emitted, layout, warnings and dependency status

bench_layer / dry_run_layer_paint

Server

Runs a layer's layout and paint and grades or measures them

wait_for_preview / inspect_preview / get_indicator_logs

Browser

Reads what the builder's chart calculated and logged

search_indicators / resolve_dependency_contract

Server

Finds a dependency and its exact accessor keys and latest version

request_add_indicator

Browser, asks you

The Indicator proposal card

update_title

Server

Names the indicator on your first message, and renames it when its purpose changes

What it checks before it calls a change done

  • Every ctx.* call has a matching output.* declaration of the right kind. output.priceLine pairs with ctx.hline(id, price); output.hline pairs with ctx.hline(id, price, { time1 }). Mixing them draws nothing.

  • Every output lands on the pane it was meant for: the dry run's layout.empty_panes is empty.

  • A marker's price goes only with the atPrice* positions.

  • mode: "invalidateOnCustomFunction" on a range or hline has an invalidateWhen, and every hline emit under it passes time1.

  • Every ctx.params.<id> has an input, every input id is unique, and every dependency pins the version the search or approval returned.

  • Cross-bar state lives in ctx.accum, warmup is declared, and a signal that must wait for the close guards on ctx.barConfirmed === false.

  • A timeframe is a literal, "chart" or an input.timeframe handle, and nothing draws inside a timeframe handler.

  • Time-zone conversions use Intl.DateTimeFormat, never a fixed UTC offset.

  • A layer's bench_layer verdict is pass at all three bar spacings.

Asking well

Good requests name the output and the behaviour:

  • "Add a 20-period EMA overlay with a length input and a colour setting."

  • "Depend on ATR and draw close ± 1 ATR bands."

  • "Keep it an overlay; do not move it to a pane."

  • "The level on 12 March sits one bar late. Fix the anchor."

Requests it cannot do: emitting events (write a definition), putting study numbers on the chart (use Attach to chart), or importing npm packages (the sandbox has none).