> Every Taji docs page as Markdown: https://docs.taji.is/llms.txt

# Outputs: what an indicator serves

This page lists what an indicator serves to every client and how each part is drawn. An indicator serves columns of numbers, one value per bar, plus the drawings and tables it holds now. The kernel computes them and serves them as rows keyed by bar open time, with the look beside them as metadata. The window draws those rows, your agent reads them, and an alert compares them; no client computes an indicator's value ([0001](https://github.com/TajiAI/Taji/blob/main/docs/decisions/0001-kernel-computes.md)).

## What does an indicator serve?

```mermaid
flowchart LR
  next["next returns {plot: number, colors}"] --> cols["columns: a value and a colour per bar"]
  draw["line.new, label.new, box.new, polyline.new, table.new, card, bars"] --> set["the drawings held now"]
  cols --> served["Arrow rows by start_dt, look as metadata"]
  set --> served
  style["params.style, offset"] -->|"look only"| served
  served --> window["window: draws"]
  served --> agent["agent: GET /get/indicators"]
  cols --> alert["alert: one plot of a pinned version"]
```

Read it from the left. Each call to `next` adds one row to the columns; each drawing call changes the set of drawings the instance holds. The kernel serves both as one Arrow batch of rows keyed by `start_dt`, the bar's open time. The binding's look, `params.style` and `offset`, joins the served metadata and never the computation. The window and your agent read the same rows; an alert reads one plot's column.

## What does a script that serves all of this look like?

Trend Band draws a 20-bar average of the close and a band 2% either side of it. The band is shaded, and the average is green while the close is at or above it, red while below:

```ts file="examples/outputs/trend_band.ts" title="trend_band.ts"
import { fill, indicator, input, plot, ta } from "@taji/indicators";

export default indicator({
  name: "Trend Band",
  pane: "price",
  inputs: { length: input.int(20, { min: 2 }), percent: input.float(2, { min: 0.1 }) },
  plots: {
    upper: plot.line({ title: "Upper", color: "#787b86" }),
    lower: plot.line({ title: "Lower", color: "#787b86" }),
    mid: plot.line({ title: "Mid", colors: ["#26a69a", "#ef5350"], width: 2 }),
  },
  fills: { band: fill("upper", "lower", { color: "#2962ff", alpha: 0.1 }) },
  setup: ({ inputs }) => ({ avg: ta.sma(inputs.length) }),
  next(bar, s, { inputs }) {
    const mid = s.avg.next(bar.close);
    const k = inputs.percent / 100;
    return { upper: mid * (1 + k), lower: mid * (1 - k), mid, colors: { mid: bar.close >= mid ? 0 : 1 } };
  },
});
```

![Trend Band over a daily SPY chart: a shaded band 2% either side of a 20-bar average drawn green above the close and red below](https://raw.githubusercontent.com/TajiAI/Taji/main/docs/indicators/examples/outputs/shot.png)

1. **`pane: "price"`** draws over the bars, on the price scale.
2. **`inputs`** declares the average's length and the band's width in percent, 20 and 2 by default; the legend prints them after the name.
3. **`plots`** declares three outputs. `upper` and `lower` take one static colour each. `mid` takes a palette of two colours, `colors: [...]`, instead of one.
4. **`fills`** shades between `upper` and `lower` in `#2962ff`, scaled to 10% opacity by `alpha`.
5. **`setup`** creates the average; **`next`** returns one number per plot, and under `colors` the slot of `mid`'s palette for this bar: 0 (green) at or above the average, 1 (red) below.

The kernel serves these rows:

```json file="examples/outputs/trend_band.json"
[
  {
    "start_dt": "2026-11-19T00:00:00+00:00",
    "upper": 134.28657,
    "lower": 129.02043,
    "mid": 131.6535,
    "mid:color": 0
  },
  {
    "start_dt": "2026-11-20T00:00:00+00:00",
    "upper": 134.71854,
    "lower": 129.43546,
    "mid": 132.077,
    "mid:color": 0
  },
  {
    "start_dt": "2026-11-23T00:00:00+00:00",
    "upper": 135.08420999999998,
    "lower": 129.78679,
    "mid": 132.4355,
    "mid:color": 0
  },
  {
    "start_dt": "2026-11-24T00:00:00+00:00",
    "upper": 135.41214,
    "lower": 130.10186000000002,
    "mid": 132.757,
    "mid:color": 0
  },
  {
    "start_dt": "2026-11-25T00:00:00+00:00",
    "upper": 135.77577,
    "lower": 130.45122999999998,
    "mid": 133.1135,
    "mid:color": 0
  },
  {
    "start_dt": "2026-11-27T00:00:00+00:00",
    "upper": 136.1241,
    "lower": 130.78589999999997,
    "mid": 133.45499999999998,
    "mid:color": 0
  },
  {
    "start_dt": "2026-11-30T00:00:00+00:00",
    "upper": 136.44132000000002,
    "lower": 131.09068000000002,
    "mid": 133.76600000000002,
    "mid:color": 0
  },
  {
    "start_dt": "2026-12-01T00:00:00+00:00",
    "upper": 136.81871999999998,
    "lower": 131.45328,
    "mid": 134.136,
    "mid:color": 0
  },
  {
    "start_dt": "2026-12-02T00:00:00+00:00",
    "upper": 137.14104,
    "lower": 131.76296,
    "mid": 134.452,
    "mid:color": 0
  },
  {
    "start_dt": "2026-12-03T00:00:00+00:00",
    "upper": 137.55465,
    "lower": 132.16035000000002,
    "mid": 134.85750000000002,
    "mid:color": 0
  }
]
```

*Captured 2026-12-04 on a headless kernel reading a made-up daily series for SPY. The rows are the newest ten; yours differ with the market.*

- Each row is one bar, keyed by `start_dt`, with one column per plot in declaration order. On 2026-12-03, `mid` is 134.8575, and `upper` and `lower` are 2% either side: 137.55 and 132.16, as the legend prints them.
- `mid:color` is the slot column the palette added: 0 (green) on every row here, the close over its average. In the picture, the line is red through July, while the close was under it, and green after.
- The fill has no column: it takes one colour, so it travels in the metadata, as `upper`'s and `lower`'s colours do. Only a painted plot or fill adds a column.

## How is a plot a column?

`plots: { mid: plot.line() }` declares an output. On every bar, `next` returns `{ mid: number }`, and that number is the bar's row in the `mid` column. A column is one 64-bit float per bar.

Rows are keyed by the bar's open time, `start_dt`, never by its index. A tick replaces one row; a recompute replaces the rows from the first that changed. The window splices either into what it holds by time ([execution.md](https://docs.taji.is/indicators/execution.md)).

A missing value is `NaN`, or a plot left out of the return. A value that is not a number is `NaN` too. It is served as null, and null draws nothing.

## What does a plot's kind tell the window?

The kind says what the number means:

| Kind | What the number is |
|---|---|
| `line`, `step`, `area`, each with a `_breaks` form; `step_diamonds` | a point on the pane's scale; a `_breaks` form leaves a gap where a value is missing |
| `histogram`, `columns` | the top of a bar from zero |
| `circles`, `cross` | a mark at the value |
| `char` | where one character sits: above, below or on the value |
| `marker` | where a triangle or circle sits above or below its bar: wherever the value is a number |
| `arrow` | a direction and size off the price scale: up for a positive value, down for a negative one, longer the larger |
| `bgcolor`, `barcolor` | a switch off the price scale: the pane's background, or the chart's candle, is coloured over each bar whose value is a number |
| `candle`, `bar` | one of four: `next` returns `{open, high, low, close}`, served as four columns `<plot>.open` to `<plot>.close` and drawn as one series |
| `plot.levels([30, 70])` | not a column: fixed horizontal lines, served in the binding's metadata. `next` never returns them |

A plot may state a `unit`, one of a card's (`price`, `usd`, `shares`, `contracts`, `ratio`, `percent`, `count`). When every plot in a pane states the same unit, the pane's axis and legend print as a card does (`+16.70 M`).

## How does a bar get its colour?

A plot takes colour one of three ways, never two at once:

| Way | The script writes | The kernel serves |
|---|---|---|
| Static | `color: "#26a69a"`; with none, `#2962ff` | the colour once, in the column's metadata |
| Palette | `colors: [...]`, 1 to 8 colours, and `next` returns `colors: { <plot>: slot }` | the slot per bar, a one-byte column `<plot>:color` beside the value |
| Computed | `colors: "computed"`, and `next` returns a colour per bar (`color.from_gradient`, `color.rgb`) | the colour per bar, a 32-bit RGBA column |

A slot that is not an integer inside the palette draws nothing for that bar. A malformed computed colour throws.

Why a palette? It keeps what the script decides apart from how it looks. Which slot a bar takes is part of the result: Trend Band decides "above" or "below". The palette's colours are look, and the binding's `style` can swap them for another palette of the same length without recomputing anything. A computed colour is result throughout, so the Style dialog offers it no swatch.

## What does a fill shade?

`fills: { band: fill("upper", "lower") }` shades between two edges. Each edge is a plot on the price scale, a level's value or a constant, and at least one is a plot or a level. A fill takes colour as a plot does: one colour, a palette whose slot `next` returns under the fill's name, or computed. `alpha`, 0 to 1, scales a colour that carries no alpha of its own.

An edge needs a line to fill to, so a fill's plot is never an `arrow`, `candle`, `bar`, `bgcolor` or `barcolor`.

## What are drawings and tables?

`line.new`, `label.new`, `box.new`, `polyline.new`, `table.new`, `card` and `bars` add to a set of drawings the instance holds now, beside its columns. A script calls them in `next` only; in `setup` they throw.

Drawings are state. A close commits them, a tick's changes are undone at the next tick, and a recompute starts with none and rebuilds them. A replay and live therefore end with the same set ([execution.md](https://docs.taji.is/indicators/execution.md)).

Each drawing places x by bar index (a `ctx.index`) or by time (a `bar.time`, the future included). A bar index reaches from 10,000 bars before the bar it is written on to 500 after; past that the call throws. Either form is served as a time. An x past the last bar or before the first is served on that end's bar spacing, with how many bars it lies off the series.

| Kind | What it is | Where it sits |
|---|---|---|
| line, label, box, polyline | a mark at prices and times | on the chart |
| table | up to 20 columns by 100 rows of cells | one of nine fixed places on the pane |
| card | 1 to 12 labelled values under a pill and a caption | one of the nine places |
| bars | one signed bar per category, 1 to 50 | the binding's own pane, which it takes whole |

A place holds one table or one card, the newest winning. Only a definition with `pane: "own"` and no plots may draw `bars`. A card's and a bars panel's values are numbers with a unit, which the window formats, never script text.

Each kind of mark has a cap, 50 by default and set in the definition (`max_lines`, `max_labels`, `max_boxes`, `max_polylines`). A kind holds up to its cap plus 5; the next one deletes its oldest down to the cap, and the evicted handles' `get()` returns null.

## What does a client receive?

`GET /get/indicators?chart=…&binding=…` answers one binding as one Arrow IPC batch:

1. `start_dt`.
2. A nullable float column per output, in declaration order.
3. A slot column per painted output (`<output>:color`) and per painted fill (`fill:<k>`).

Each column carries its own metadata: an output's kind, title, colours and width. The batch carries the binding's: its name and `definition` (`name@N`), its pane, its legend, levels and fills, `drawings` while it holds any, `repaints` when it may repaint, and `fault` when it computes nothing. `describe {route: "get/indicators"}` serves the full field list. The agent's bridge decodes the batch to `{meta, fields, rows}`.

The window reads the same bytes live, on `/ws/market`'s `indicators` stream: one per chart, one binding a frame. A frame's rows replace every row the window holds for that binding at or after the frame's first `start_dt`. `meta.drawings` carries the whole set each time, so a frame never depends on an earlier one's drawings.

A script with no plots serves rows of `start_dt` alone and no `fields`; it may still draw.

## Why does changing the look recompute nothing?

The look is not part of what an instance computes. A binding's `params.style` sets:

- each output's visibility, colour or palette, width, kind among the eleven plot styles from `line` to `circles`, price line and dash;
- each fill's and level's look, and a level's value;
- which parts show, the precision of printed values (0 to 8 decimals), and the intervals the binding shows on.

`offset` shifts every plot a number of bars as drawn, up to 500 either way.

Neither is part of the instance's key. Editing them resends the binding's rows with the new look and recomputes nothing: the same values, drawn differently. Two bindings that differ only in look share one instance.

That is also why a script's plot declares only its title, colour or palette, width and unit. Offset, precision and visibility belong to the binding, so they are set in the binding's settings, not in the definition.

## Who reads the outputs?

| Reader | What it reads |
|---|---|
| The window | the rows and metadata as served; it turns the kernel's words and numbers into marks and pixels, and computes no value |
| Your agent | the same rows, with `GET /get/indicators`, so the number it reasons about is the number you see |
| An alert | one plot of an indicator, its definition pinned at creation to its version (`name@N`), so a later write never changes what a standing alert compares |
| Another indicator | a plot, as its `source` input ([inputs.md](https://docs.taji.is/indicators/inputs.md)) |

An alert reads the chart's own instance where a chart shows that indicator on that series. An indicator with no plot cannot be an alert's operand: the alert is refused with `<name> draws no plot`.

## How much can a definition serve?

| Limit | Value |
|---|---|
| Columns | 32, a `candle` or `bar` counting four (one plot of every kind takes 23) |
| Fills | 16 |
| A palette | 1 to 8 colours |
| A title | 1 to 64 characters |
| A width | 1 to 4 |
| Lines, labels, boxes per kind | cap 1 to 500, default 50 |
| Polylines | cap 1 to 100, default 50; up to 10,000 points each |
| A drawing's text | 40,960 UTF-16 units |

`colors` is not a plot name: it is where `next` returns colours.

A binding under `calc` serves a value only on the first chart bar and on the one that closes each `calc` bar, null between, unless `calc_closes` is off; that and repainting are [execution.md](https://docs.taji.is/indicators/execution.md)'s.

## See also

- [Plots and colour](https://docs.taji.is/skill/references/indicators.md#plots-and-colour): every kind and option.
- [Drawings and tables](https://docs.taji.is/skill/references/indicators.md#drawings-and-tables): every drawing call and its defaults.
- [Reading it back, and the look](https://docs.taji.is/skill/references/indicators.md#reading-it-back-and-the-look): every served field and `style` key.
- [Execution](https://docs.taji.is/indicators/execution.md): ticks, closes, recomputes and `calc`.
- [Inputs](https://docs.taji.is/indicators/inputs.md): reading another indicator's plot.
