Skip to main content

Have your agent write an indicator

You ask your agent for an indicator in one sentence, and it writes the source, has the kernel check it, binds it under your chart and reads its values back, in three tool calls you can follow one by one.

You need your agent connected to Taji over MCP and a daily equity:SPY chart, the chart a new desk opens with.

You type:

Add an indicator under my SPY chart that shows how far each close is above or below its 20-day average, in percent, then read me its values from November 18 to December 2.

Once it has your desk's id, your agent makes three tool calls. calls.json lists the wire request each one makes, in order; {desk} stands for your desk's id, which the agent reads off read/desks, and {bind.node | split("/") | last} for the binding's id, the end of the bind answer's node:

calls.json
[
{"name": "write", "method": "POST", "route": "/verb/desk/{desk}/indicators/write", "body": {"name": "stretch", "source": {"$file": "stretch.ts"}}},
{"name": "bind", "method": "POST", "route": "/verb/desk/{desk}/chart/1/add_indicator", "body": {"pane_id": 1, "definition": "stretch", "params": {}}},
{"name": "rows", "method": "GET", "route": "/get/indicators?chart=desk/{desk}/chart/1&binding={bind.node | split(\"/\") | last}&from=2026-11-18T00%3A00%3A00Z&to=2026-12-02T00%3A00%3A00Z", "until": "length >= 1", "shot": true}
]

The source it writes:

stretch.ts
import { indicator, input, plot, ta } from "@taji/indicators";

export default indicator({
name: "Stretch",
pane: "own",
inputs: { length: input.int(20, { min: 2 }) },
plots: { stretch: plot.columns({ title: "Stretch %" }) },
setup: ({ inputs }) => ({ avg: ta.sma(inputs.length) }),
next(bar, s) {
return { stretch: (bar.close / s.avg.next(bar.close) - 1) * 100 };
},
});

A daily SPY chart with a Stretch 20 pane under it: blue columns above zero where the close is over its 20-day average and below zero where it is under, highest in early December

Each tool call is one request to the wire. The bridge adds the leading /, URL-encodes a query and sends every request with the agent token.

  1. call {route: "verb/desk/<id>/indicators/write", body: {name: "stretch", source: "<the source above>"}} is POST /verb/desk/{desk}/indicators/write. call sends a route whose effect is write. The kernel compiles the source, runs it over its own fixture bars, checks it and stores it as the desk's next version; the answer is the check report.
  2. call {route: "verb/desk/<id>/chart/1/add_indicator", body: {pane_id: 1, definition: "stretch", params: {}}} is POST /verb/desk/{desk}/chart/1/add_indicator. It binds the indicator to chart 1; params: {} takes the defaults, so the legend reads Stretch 20. The answer's node ends in the binding's id.
  3. read {route: "get/indicators", query: {chart: "desk/<id>/chart/1", binding: "<the binding's id>", from: "2026-11-18T00:00:00Z", to: "2026-12-02T00:00:00Z"}} is GET /get/indicators with that query. from and to bound the rows to the span you asked for, both ends included.

The source is the smallest that does what you asked. pane: "own" draws it in a pane under the chart. inputs makes the 20 a setting, length. setup creates a 20-bar simple moving average once, and next returns each close's distance from it in percent.

The answer to the write, the check report:

{
"definition": "stretch@1",
"report": {
"bars": 1024,
"drawings": {
"bar_categories": 0,
"boxes": 0,
"cards": 0,
"labels": 0,
"lines": 0,
"polylines": 0,
"tables": 0
},
"fault": null,
"invariants": [
{
"detail": null,
"name": "determinism",
"ok": true
},
{
"detail": null,
"name": "prefix",
"ok": true
},
{
"detail": null,
"name": "ticks_then_close",
"ok": true
}
],
"logs": [],
"ms": 10.574916,
"plots": [
{
"first": 1705671900,
"last": 0.2144485349478531,
"max": 1.607397375615638,
"min": -1.9610823188493942,
"na": 19,
"name": "stretch"
}
],
"tests": []
}
}
  • definition is stretch@1, the first stored version. A binding that names stretch follows the latest one.
  • fault is null and each invariant holds, so the kernel stored it. A source that fails is refused with this report and nothing is stored; your agent fixes the source and writes again.
  • The report covers the kernel's fixture of 1,024 synthetic bars, not your chart: na is 19 because the average needs 20 bars before its first value.

The answer to the bind:

{
"node": "desk/01a24251-bb2e-74cf-a574-52f58b5b9317/chart/indicators/01a24251-bcd3-7269-b1b9-2c1cd414f9b7",
"seq": 1796408982161432
}

The wire answers the read in Arrow IPC; the bridge hands your agent these rows, with each plot's look beside them:

[
{
"start_dt": "2026-11-18T00:00:00+00:00",
"stretch": 0.7017196321495778
},
{
"start_dt": "2026-11-19T00:00:00+00:00",
"stretch": 2.1241364642793137
},
{
"start_dt": "2026-11-20T00:00:00+00:00",
"stretch": 2.4932425781930334
},
{
"start_dt": "2026-11-23T00:00:00+00:00",
"stretch": 3.2653631390374915
},
{
"start_dt": "2026-11-24T00:00:00+00:00",
"stretch": 3.4371068945517003
},
{
"start_dt": "2026-11-25T00:00:00+00:00",
"stretch": 4.820322506732988
},
{
"start_dt": "2026-11-27T00:00:00+00:00",
"stretch": 4.537109887227908
},
{
"start_dt": "2026-11-30T00:00:00+00:00",
"stretch": 4.608046887848927
},
{
"start_dt": "2026-12-01T00:00:00+00:00",
"stretch": 4.684797518936001
},
{
"start_dt": "2026-12-02T00:00:00+00:00",
"stretch": 5.011453901764207
}
]

Captured 2026-12-04 on a headless kernel reading a made-up daily series for SPY.

  • Each row is one daily bar, keyed by its open time, start_dt, with one column per plot.
  • stretch is the close's distance from its 20-day average, in percent. It is positive on every row, rising from 0.70% on 2026-11-18 to 5.01% on 2026-12-02, the last bar you asked for, as the close climbs away from its average.
  • The 2026-11-26 holiday has no bar, so it has no row.

Change it​

Bind it with a 50-day average, without writing the source again:

- {"name": "bind", "method": "POST", "route": "/verb/desk/{desk}/chart/1/add_indicator", "body": {"pane_id": 1, "definition": "stretch", "params": {}}},
+ {"name": "bind", "method": "POST", "route": "/verb/desk/{desk}/chart/1/add_indicator", "body": {"pane_id": 1, "definition": "stretch", "params": {"length": 50}}},

Ask for an exponential average instead; the agent's next write is stretch@2, and the binding follows it:

- setup: ({ inputs }) => ({ avg: ta.sma(inputs.length) }),
+ setup: ({ inputs }) => ({ avg: ta.ema(inputs.length) }),

Pin the binding to the first version, so a later write does not change what the chart draws:

- {"name": "bind", "method": "POST", "route": "/verb/desk/{desk}/chart/1/add_indicator", "body": {"pane_id": 1, "definition": "stretch", "params": {}}},
+ {"name": "bind", "method": "POST", "route": "/verb/desk/{desk}/chart/1/add_indicator", "body": {"pane_id": 1, "definition": "stretch@1", "params": {}}},

Next​