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

# Indicators

**A Taji indicator is a TypeScript module your agent writes and the kernel computes once, on your machine, so the window, your agent and an alert read the same values.** This page says what that gives you, shows one indicator file part by part, and then says what holds an indicator to its word.

- **Optimized for coding agents, not for hand-coding.** Taji has no proprietary language. An indicator is TypeScript and heavy computation is Rust: industry-standard languages that give your agent the best tools there are for safety, performance and writing correct code ([why TypeScript](https://docs.taji.is/indicators/sdk.md#why-typescript)).
- **Computed once, served to every client.** One instance per definition, inputs and series computes the rows; the window draws them, your agent reads them and an alert tests them, so no two can disagree ([0001](https://github.com/TajiAI/Taji/blob/main/docs/decisions/0001-kernel-computes.md)).
- **Your machine, no daily limits.** The kernel runs the script in V8 inside its own process, and your agent writes, checks and rewrites over MCP with no daily count.
- **The whole market.** A script reads other intervals and symbols, dividends, splits and earnings, the hub's trades, quotes, statistics and imbalance products, and any plugin's product ([Inputs](https://docs.taji.is/indicators/inputs.md)). Beside it stand 106 built-in indicators in Rust, compiled into the kernel.

## How does an indicator get from your agent to a chart?

```mermaid
flowchart LR
  write["your agent writes source and test"] --> check{"compiles, holds three invariants, test passes?"}
  check -->|"no"| refused["422: line and column, nothing stored"]
  check -->|"yes"| version["immutable version name@N"]
  version --> bind["binding on a chart pane, or an alert"]
  bind --> instance["one instance per definition, inputs and series"]
  instance --> clients["the same rows to window, agent, alert"]
```

Read it from the left, in three steps:

1. **Write.** Your agent sends the source, and optionally a test, to `indicators/write` on your desk. A refused write answers 422 with the line and column, which is your agent's next edit; a passing one is stored as an immutable `name@N`.
2. **Bind.** A version bound to a chart pane, or named in an alert, gets an instance. Every binding and alert with the same definition and inputs on the same series shares it.
3. **Serve.** The instance runs over the held bars, then follows the market. Its rows, keyed by bar open time, are what the window draws, your agent reads and an alert tests.

## What does an indicator file look like?

Pulse, from [Your first indicator](https://docs.taji.is/indicators/first-indicator.md), plots each bar's percent change from the bar before and a 9-bar exponential average of that change:

```ts file="examples/first-indicator/pulse.ts" title="pulse.ts"
import { indicator, input, plot, ta } from "@taji/indicators";

export default indicator({
  name: "Pulse",
  pane: "own",
  inputs: { length: input.int(9, { min: 2 }) },
  plots: { change: plot.line({ title: "Change %" }), avg: plot.line({ title: "Average" }) },
  setup: ({ inputs }) => ({ prev: NaN, avg: ta.ema(inputs.length) }),
  next(bar, s) {
    const change = (bar.close / s.prev - 1) * 100;
    s.prev = bar.close;
    return { change, avg: s.avg.next(change) };
  },
});
```

![Pulse in its own pane under a daily SPY chart, its legend reading Pulse 9 1.01 0.62](https://raw.githubusercontent.com/TajiAI/Taji/main/docs/indicators/examples/first-indicator/shot.png)

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

1. **`import`** names `@taji/indicators`, the only module a script may import.
2. **`pane: "own"`** draws Pulse in a pane under the chart; `"price"` would draw it over the candles.
3. **`inputs`** declares `length`, a whole number from 2 up, 9 by default. One declaration becomes both the window's settings dialog and your agent's schema.
4. **`plots`** names two columns, `change` and `avg`; every row the kernel serves has one value for each.
5. **`setup`** runs once per instance and returns the state: the previous close, kept by hand, and a `ta.ema` handle, which only `setup` may create.
6. **`next`** runs once per bar and returns one number per plot. On the first bar `s.prev` is `NaN`, so `change` is `NaN` and nothing is drawn there.

[Your first indicator](https://docs.taji.is/indicators/first-indicator.md) follows this file through the write's report, the binding and the rows it serves.

## Which indicators are built in, and which does your agent write?

Two kinds exist, and they behave the same once bound to a chart.

| Kind | Where it lives | Versions |
|---|---|---|
| Built-in | 106 definitions compiled into the kernel in Rust (`substrate/taji-indicators/src/defs.rs`): moving averages, momentum, volatility, trend, volume and session indicators | One. Any `@N` binds it |
| Custom | A TypeScript module your agent writes into a desk; it belongs to that desk | Each passing write is a new, immutable `name@N` |

Computation you want in Rust goes in a [feature plugin](https://docs.taji.is/plugins/feature.md), which serves a product an indicator reads and draws. A plugin can register scripts of its own ([Your first plugin](https://docs.taji.is/plugins/first-plugin.md#3-add-the-indicator)).

## What holds an indicator to its word?

- **Checked on every write.** The kernel compiles the source, runs it over a fixed fixture and refuses it, with the line and column and nothing stored, unless `determinism`, `prefix` and `ticks_then_close` hold and its test passes ([What does a write check?](https://docs.taji.is/indicators/execution.md#what-does-a-write-check)).
- **Versioned.** Each passing write is an immutable `name@N`: a bare name follows the latest, and an alert pins the version it was made with ([What happens to an older version?](https://docs.taji.is/indicators/execution.md#what-happens-to-an-older-version)).
- **Shared.** Every binding and alert with the same definition, inputs and series reads one instance, so the legend and an alert read the same value and a colour change recomputes nothing ([Who shares a computation?](https://docs.taji.is/indicators/execution.md#who-shares-a-computation)).
- **Refused.** Any import but `@taji/indicators`, TypeScript that needs generated code, and state the kernel cannot copy never reach a chart, and a script that reads the clock or a random number throws ([what the write refuses](https://docs.taji.is/indicators/sdk.md#what-does-the-kernel-refuse-at-the-write), [why no clock](https://docs.taji.is/indicators/sdk.md#why-cant-a-script-read-the-clock)).
- **Faults alone.** A script that throws, runs past its budget or exceeds its memory clears only its own rows and shows a red `!` in the legend, and the lane bounds a script without containing a hostile one ([What happens when a script faults?](https://docs.taji.is/indicators/execution.md#what-happens-when-a-script-faults), [Security](https://docs.taji.is/architecture/security.md)).

## See also

- **New here?** [Your first indicator](https://docs.taji.is/indicators/first-indicator.md): write, check, bind, read, test and fault one.
- **Coming from Pine?** [Taji indicators and plugins vs Pine Script](https://docs.taji.is/indicators/pine.md): the two side by side.
- **Writing with an agent?** [Have your agent write an indicator](https://docs.taji.is/cookbook/agent-writes-an-indicator.md): one sentence to you, three tool calls to the kernel.
- **Need Rust speed?** [Build a feature plugin](https://docs.taji.is/plugins/feature.md): a Rust product that an indicator reads and draws.
- [The indicator SDK](https://docs.taji.is/indicators/sdk.md): TypeScript, the module's shape, `NaN`, state, what is refused.
- [How an indicator executes](https://docs.taji.is/indicators/execution.md): the lane, instances, ticks and closes, origin, budgets, faults, versions.
- [Inputs](https://docs.taji.is/indicators/inputs.md): tunable inputs, per-bar sources and anchors, declared data reads.
- [Outputs](https://docs.taji.is/indicators/outputs.md): plots, colour, fills, drawings and tables, the served shape, the look.
- [The indicator reference](https://docs.taji.is/skill/references/indicators.md) and [`taji.d.ts`](https://github.com/TajiAI/Taji/blob/main/agent/skills/taji/references/taji.d.ts): every field, kind, default and limit, and the types your agent's source must fit. They ship with the skill and never depend on these pages.
