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

# Taji indicators and plugins vs Pine Script

Taji indicators and plugins are written for coding agents first, because that is how software is written now. Taji has no language of its own: an indicator is TypeScript, and a plugin is Rust, the language of Taji's own kernel and its 106 built-in indicators, or Python. Their compilers, type checkers and test runners are the ones every coding agent already uses, so your agent writes with the best tools there are for safety, performance and correct code. An indicator is Pine's level, a figure per bar on a chart; a plugin goes deeper than any Pine script, adding a backend, views in Taji's window and indicators of its own. Pine Script is TradingView's own language, written in its Pine Editor and run on its servers.[^welcome][^first]

| | Taji | Pine Script |
|---|---|---|
| Language | TypeScript for indicators; Rust or Python for plugins: open and industry-standard | Pine Script v6, TradingView's own[^welcome] |
| Written by | Your coding agent, such as Claude Code, Codex or Cursor, from a prompt | You, in the Pine Editor;[^first] an agent only through TradingView's MCP server, 10 to 500 calls a day by plan[^mcp] |
| Checked before it runs | Your agent's type checker against `taji.d.ts`, then the compiler, three invariants and your own tests, on every write | The compiler[^mcp] |
| Reads | Bars, events, the tape, quotes and auction imbalance; through a plugin, the order book, option chains with greeks and any vendor or file | Bars, events, financials, economic series and a volume footprint; bid, ask and the aggressor on 1-tick charts[^otf][^release] |
| Speed | `ta` primitives and the built-ins are compiled Rust; your script runs in V8 on your machine | Limited in execution time, memory and size on TradingView's servers[^welcome][^limits] |
| Where it runs | Your machine | TradingView's servers[^welcome] |

Every statement about Pine cites the page of the Pine Script v6 User Manual, TradingView's blog or its help center it comes from, fetched 2026-12-03; v6 is the version TradingView updates.[^release]

## Indicator or plugin?

**Taji extends at two levels. An indicator is the level a Pine script works at; a plugin adds what no Pine script can.**

| | Taji indicator | Taji plugin | Pine script |
|---|---|---|---|
| What it is | One TypeScript module on `@taji/indicators` ([The indicator SDK](https://docs.taji.is/indicators/sdk.md)) | A directory: a manifest, `taji-plugin.toml`, and the code that serves what it declares ([Plugins](https://docs.taji.is/plugins.md#what-is-a-plugin)) | One script, declared with `indicator()`, `strategy()` or `library()`[^structure] |
| Language | TypeScript | Rust or Python for its process; TypeScript for its panes, layers and indicators | Pine Script v6[^welcome] |
| What it adds | Plots, fills, drawings and a table or card on a chart ([Outputs](https://docs.taji.is/indicators/outputs.md)) | Verbs your agent calls as tools and nodes it reads; data sources, and products of its own computed from Taji's data or a vendor's; panes in Taji's window; chart layers drawn from its products; indicators of its own ([Which kind do I need?](https://docs.taji.is/plugins.md#which-kind-do-i-need)) | Plots, drawings and tables on a chart;[^limits] a strategy's simulated orders in the Strategy Tester[^strategies] |
| What it reads | The chart's bars, other bars, events and the hub's products, a plugin's included ([Inputs](https://docs.taji.is/indicators/inputs.md#how-does-a-script-read-another-series)) | Every hub product its manifest grants, the order book and option chains included; as a source, a vendor through the hosts its manifest grants, or files in its own directory | Its chart's data and the `request.*()` functions[^otf] |
| Where it runs | The kernel on your machine, in V8 | Its own process on your machine, in an OS sandbox that reaches only the hosts its manifest grants; its panes in a sandboxed frame of Taji's window | TradingView's servers[^welcome] |
| Who uses it | You and your agent bind it to a chart, and an alert reads its plot | Your agent calls its verbs and reads its nodes; Taji's window draws its panes and layers; your indicators read its products | You, on a TradingView chart[^first] |

Write an indicator for a figure per bar from data Taji already serves; write a plugin when the data needs a backend first, such as a book, a chain or a vendor, or when it needs a view of its own. Everything Taji does beyond its core is a plugin, the chart included.

## What each can read

Each row says whether an indicator reads the data directly or a plugin brings it, and where it comes from. "Your provider" is a linked data source or brokerage; [Data coverage](https://docs.taji.is/reference/coverage/data.md) names which serves what. Yahoo needs no key.

| Data | Taji | Pine |
|---|---|---|
| Bars and volume | Indicator: `bar`, at 1 minute to a year; from Yahoo or your provider ([Inputs](https://docs.taji.is/indicators/inputs.md#what-do-bar-and-ctx-hold)) | The chart's bars, 1-tick to 1,000-tick charts among them[^exec][^ticks] |
| Other symbols and intervals | Indicator: `data.bars({ symbol, interval })`, up to 8 `data` entries ([Inputs](https://docs.taji.is/indicators/inputs.md#how-does-a-script-read-another-series)) | `request.security()`, up to 40 unique requests a script (64 on Ultimate)[^otf] |
| The finer bars inside a bar | Indicator: `.intrabars` on a finer `data.bars` entry, the newest 200,000 ([Inputs](https://docs.taji.is/indicators/inputs.md#how-does-a-script-read-another-series)) | `request.security_lower_tf()`; up to 100,000 intrabars on Basic to Premium, 200,000 on Ultimate[^otf][^limits] |
| Dividends, splits, earnings | Indicator: `data.events("dividends")`, `"splits"`, `"earnings"`, each from the first bar it is knowable | `request.dividends()`, `request.splits()`, `request.earnings()`[^otf] |
| The trade tape | Indicator: `data.product("trades")`, each print with its aggressor where the source states it; Yahoo streams it live | On a 1-tick chart, a bar per tick, with `aggressor_side` since November 2026[^ticks][^release] |
| Best bid and ask | Indicator: `data.product("quotes")`, bid and ask with their sizes; Yahoo streams them | `bid` and `ask`, on the 1-tick timeframe only[^release] |
| Auction imbalance | Indicator: `data.product("imbalance")`, the imbalance a venue publishes before an open or close, from your provider | None of the `request.*()` functions[^otf] |
| The order book, level by level | Plugin: streams the hub's `depth` and serves rows an indicator reads, as [Order flow](https://docs.taji.is/catalog/taji-orderflow.md)'s `taji-orderflow.book`; from your provider | None of the `request.*()` functions[^otf] |
| Buy and sell volume | Plugin: Order flow's `prints` and `delta`, each print's side the feed's or the tick rule's; its `cvd` indicator sums the delta | `request.footprint()`, buy and sell volume by price row, classed from intrabar price action; one call a script, Premium or Ultimate[^otf] |
| Off-exchange prints | Plugin: [Dark pool](https://docs.taji.is/catalog/taji-darkpool.md)'s `taji-darkpool.prints` and `levels`, the prints reported to a FINRA facility; from your provider | None of the `request.*()` functions[^otf] |
| Option chains with greeks | Plugin: reads `chains`, each contract's IV, delta, gamma, theta, vega and rho, computed by Taji where the vendor sends none; Yahoo's delayed chain | None of the `request.*()` functions[^otf] |
| Dealer gamma exposure | Plugin: [GEX](https://docs.taji.is/catalog/taji-gex.md)'s levels, strikes, curve and expiries, which an indicator reads with `data.product("taji-gex.levels")`; from Yahoo's delayed chain | None of the `request.*()` functions[^otf] |
| Any vendor or file | Plugin: a data source in Python or Rust serves bars or a product of its own ([Add a data source](https://docs.taji.is/plugins/source.md)) | `request.seed()`, from a GitHub repository its author maintains[^otf] |

An indicator also reads another indicator's plot, built-in or custom, through a `source` input, and the kernel computes that indicator first ([Inputs](https://docs.taji.is/indicators/inputs.md#why-is-a-source-or-an-anchor-a-value-per-bar)). What Pine reads and an indicator does not, financial statements and economic series among them, is under [Other data](#other-data).

## Indicators you can build in Taji and not in Pine

- **Dealer gamma by strike.** A plugin estimates dealer gamma exposure by strike from SPY's option chain, with the flip and the walls, and the chart draws it ([Chart dealer gamma exposure](https://docs.taji.is/cookbook/gex-profile.md)). No Pine `request.*()` function reads an option chain.[^otf]
- **An order-flow heatmap.** The book's resting size at every price behind the candles, trade bubbles from the tape and a cumulative delta pane ([Draw an order-flow heatmap](https://docs.taji.is/cookbook/orderflow-heatmap.md)). No Pine `request.*()` function reads a book;[^otf] Pine's nearest reads are `request.footprint()`, one call a script on Premium or Ultimate, and the aggressor of each tick on a 1-tick chart.[^otf][^limits][^release]
- **An indicator with its own test.** A write carries a test beside the source, and the kernel runs it with the compiler and three invariants, storing nothing that fails ([Your first indicator](https://docs.taji.is/indicators/first-indicator.md)). Pine checks a script with its compiler; its debugging tools are logs and a profiler.[^mcp][^debug][^profiling]
- **An indicator your agent iterates on all day.** Your agent writes over MCP with no daily count; TradingView's MCP server counts each call against 10 to 500 a day by plan.[^mcp]
- **Any computation in Rust.** A feature plugin computes in Rust and serves a product; an indicator reads it with `data.product(...)` and draws it ([Build a feature plugin](https://docs.taji.is/plugins/feature.md)). A Pine script is written in Pine and runs on TradingView's servers.[^welcome]

## The whole order book

**Every level of the book, every second, behind the candles.**

A plugin streams the hub's `depth`, the book a provider serves level by level, and serves its own rows from it. [Order flow](https://docs.taji.is/catalog/taji-orderflow.md) serves five: a heatmap column of each second's peak resting size at every price, the book at each second's close, the best bid and ask, the prints and the delta. Its four chart layers draw them in Taji's window, and no Pine `request.*()` function reads a book.[^otf] Registering the book product, in `plugins/taji-orderflow/src/main.rs`:

```rust
p.product::<Book>().live(|cx, sub| {
    follow(
        cx,
        sub,
        Books::of(sub.item()).every(SECOND),
        taji_orderflow::book,
    )
});
```

`Books::of(sub.item()).every(SECOND)` asks the hub for the book once a second; `taji_orderflow::book` turns each frame into a row, bids positive and asks negative. The picture is the plugin playing its own recording, not the market:

![A replayed ESZ26 1-minute chart, zoomed to a few minutes: a liquidity heatmap of coloured cells behind and after the candles, trade bubbles over it, best bid and ask lines, the resting book as bars at the right edge, and a Cumulative delta pane below](https://raw.githubusercontent.com/TajiAI/Taji/main/docs/cookbook/examples/orderflow-heatmap/shot.png)

On a real book it reads what your provider streams: [Draw an order-flow heatmap](https://docs.taji.is/cookbook/orderflow-heatmap.md#use-it-on-a-real-book).

## Who traded, and on which side

**Delta from each print's own side, summed per candle by a script of a few lines.**

Order flow gives each print a side, `1` where the buyer crossed the spread and `-1` where the seller did: the feed's where it states one, else the tick rule's estimate, marked `estimated`. Its `delta` product is each second's buy and sell size, and `cvd`, the indicator the plugin ships in `plugins/taji-orderflow/indicators/cvd.ts`, sums it, restarting each session; it is the Cumulative delta pane in the picture above. Pine's nearest reads are `request.footprint()`, which classes volume as buy or sell from intrabar price action, once a script and on Premium or Ultimate only,[^otf] and each tick's aggressor on a 1-tick chart.[^release]

```ts
import { data, indicator, input, plot } from "@taji/indicators";

export default indicator({
  name: "Cumulative delta",
  pane: "own",
  inputs: {
    session: input.anchor("session"),
  },
  data: {
    flow: data.product("taji-orderflow.delta"),
  },
  plots: {
    cvd: plot.line({ title: "CVD", unit: "count" }),
  },
  setup: () => ({ sum: 0 }),
  next(_bar, s, { inputs, data: feed }) {
    if (inputs.session.starts) s.sum = 0;
    for (const row of feed.flow.rows) s.sum += row.delta;
    return { cvd: s.sum };
  },
});
```

`feed.flow.rows` holds the delta rows that became knowable inside this bar, oldest first, so the loop adds each second once.

## The option chain

**Gamma by strike, the flip and the walls, from the chain's own IV and open interest.**

A plugin reads the hub's `chains`: each contract's quote, open interest, IV and greeks. [GEX](https://docs.taji.is/catalog/taji-gex.md) prices the chain every 60 seconds and serves dealer exposure at spot, by strike, by expiry and at hypothetical spots, each estimate marked as one. No Pine `request.*()` function reads an option chain.[^otf] The plugin's loop, in `plugins/taji-gex/src/main.rs`:

```rust
for batch in cx.stream(Chains::of(sub.item()).every(Duration::from_secs(60)))? {
    if let Some(priced) = price_batch(&batch, &opts)
        && sub.push(row(&priced)).is_err()
    {
        break;
    }
}
```

And the read in its `gex_net` indicator, `plugins/taji-gex/indicators/gex_net.ts`:

```ts
data: ({ inputs }) => ({
  gex: data.product("taji-gex.levels", { lens: inputs.lens, expiries: inputs.expiries, units: inputs.units }),
}),
```

![A replayed 1-minute S&P 500 chart with the GEX levels drawn at the right: a gold flip line, the magnet, the put wall and max pain, and at the right edge two docks, net exposure by hypothetical spot and by strike](https://raw.githubusercontent.com/TajiAI/Taji/main/docs/cookbook/examples/gex-profile/shot.png)

On a Taji with no key it reads Yahoo's delayed chain; the recipe plays the plugin's made-up chains: [Chart dealer gamma exposure](https://docs.taji.is/cookbook/gex-profile.md).

## Any vendor or file

**A data source of your own in one short Python file.**

A source plugin answers the hub's reads from a vendor or a file, and a chart pinned to it draws its bars like any other. Pine's counterpart is `request.seed()`, data from a GitHub repository its author maintains.[^otf] This one serves daily bars from a CSV in the plugin's own directory, from [Chart your own CSV of daily bars](https://docs.taji.is/cookbook/python-csv-source.md):

```python
@p.read("bars")
def bars(ask):
    path = os.path.join(os.environ["HOME"], ask["asked"] + ".csv")
    if not os.path.exists(path):
        raise taji.Refused(404, "not_listed", f"no {ask['asked']}.csv")
    lo, hi = ask["from"], ask["to"]
    rows = []
    with open(path, newline="") as f:
        for r in csv.DictReader(f):
            ts = calendar.timegm(datetime.date.fromisoformat(r["date"]).timetuple())
            if (lo is None or ts >= lo) and (hi is None or ts < hi):
                rows.append({"ts_utc": ts, **{k: r[k] for k in ("open", "high", "low", "close", "volume")}})
    return rows
```

![A daily SPY chart pinned to CSV source, drawing the CSV's bars and nothing before them](https://raw.githubusercontent.com/TajiAI/Taji/main/docs/cookbook/examples/python-csv-source/shot.png)

## Written for your agent

**Taji is built to be written by your agent; Pine is built to be written by you, in its editor.**

1. TradingView's MCP server checks Pine against the real compiler, runs indicators and backtests, and saves scripts to your account, each call counting against 10 to 500 a day by plan; protected and invite-only scripts stay closed to it.[^mcp]
2. Taji's author is your agent, with no daily count: it writes TypeScript, a language agents write fluently, sends it with `indicators/write` over MCP and binds it with `add_indicator`. A refused write answers 422 with the diagnostic's line and column or the failed invariant, which is the agent's next edit ([Your first indicator](https://docs.taji.is/indicators/first-indicator.md)).
3. Taji never type-checks; your agent's editor does, against [`taji.d.ts`](https://github.com/TajiAI/Taji/blob/main/agent/skills/taji/references/taji.d.ts), which declares `@taji/indicators` whole. A misspelt input or a plot option of the wrong type fails there, before the kernel sees the source.
4. Every distinct write is the next immutable version, `name@1`, `name@2`, a file in your desk's directory that you read and review. A binding on the bare name follows the latest; one on `name@N` and every alert stay on theirs ([Execution](https://docs.taji.is/indicators/execution.md#what-happens-to-an-older-version)). Pine versions libraries, which importers pin, and keeps a version history for published scripts.[^libraries][^publishing]

The editor's settings that make the check, with `taji.d.ts` copied beside your source:

```json
{
  "compilerOptions": {
    "target": "ESNext",
    "module": "ESNext",
    "moduleResolution": "bundler",
    "strict": true,
    "noEmit": true,
    "types": [],
    "paths": { "@taji/indicators": ["./taji.d.ts"] }
  },
  "include": ["*.ts"]
}
```

## Execution

**Both run bar by bar and roll a tick back. Pine runs on TradingView's servers; Taji runs on your machine.**

1. Pine is cloud-based: a script runs on TradingView's servers, which limit the data it requests, its execution time, its memory and its size.[^welcome] A Taji indicator runs in the kernel on your machine, in one V8 isolate on its own thread that every desk's scripts share, each distinct source in a context of its own ([Execution](https://docs.taji.is/indicators/execution.md#where-does-your-script-run)).
2. A Pine script runs from the first bar to the last, once per historical bar, then again on every tick of the open bar.[^exec] A Taji definition splits that in two: `setup` runs once per instance and returns the state, then `next` runs once per bar, oldest first, and once per tick of the forming bar ([The indicator SDK](https://docs.taji.is/indicators/sdk.md#how-does-taji-run-your-module)).
3. Before each recalculation on an open bar, Pine resets the script's data to its state when the bar opened, and only the last tick's values are committed.[^exec] Taji does the same: a tick runs `next` from the state the previous bar committed, and only a close commits; a tick's drawings and log lines roll back with it ([Execution](https://docs.taji.is/indicators/execution.md#what-happens-on-a-tick-and-on-a-close)).
4. Pine's `varip` declares a variable that does not revert to the committed state, so it can count ticks, and it can repaint.[^exec] Taji has no counterpart: every tick starts from the last close, and a write fails a script whose closed value depends on how many ticks came before it.

The same moving-average cross in each. The Pine is TradingView's own strategy example, verbatim;[^strategies] its two `strategy.entry` orders have no counterpart in an indicator, so the Taji version draws the cross as markers instead:

```ts tab={"label":"Taji"}
// Taji
import { indicator, input, plot, ta } from "@taji/indicators";

export default indicator({
  name: "Simple MA cross",
  pane: "price",
  inputs: { length: input.int(14, { min: 2, title: "Base length" }) },
  plots: {
    fast: plot.line({ title: "Fast MA", color: "#00bcd4" }),
    slow: plot.line({ title: "Slow MA", color: "#ff9800" }),
    up: plot.marker({ shape: "triangle-up", at: "below" }),
    down: plot.marker({ shape: "triangle-down", at: "above" }),
  },
  setup: ({ inputs }) => ({
    fast: ta.sma(inputs.length),
    slow: ta.sma(inputs.length * 2),
    up: ta.crossUp(),
    down: ta.crossDown(),
  }),
  next(bar, s) {
    const fast = s.fast.next(bar.close);
    const slow = s.slow.next(bar.close);
    return {
      fast,
      slow,
      up: s.up.next(fast, slow) ? bar.low : NaN,
      down: s.down.next(fast, slow) ? bar.high : NaN,
    };
  },
});
```

```pine tab={"label":"Pine"}
//@version=6
strategy("Simple strategy demo", overlay = true)
//@variable Defines the lengths of the fast and slow moving averages.
int lengthInput = input.int(14, "Base length", minval = 2)

// Calculate a fast MA using the `lengthInput` value and a slow MA using twice that value.
float fastMA = ta.sma(close, lengthInput)
float slowMA = ta.sma(close, lengthInput * 2)

// If the fast MA crosses over the slow MA, place an order to close any short position and enter a long position.
if ta.crossover(fastMA, slowMA)
    strategy.entry("Buy", direction = strategy.long)

// If the fast MA crosses under the slow MA, place an order to close any long position and enter a short position.
if ta.crossunder(fastMA, slowMA)
    strategy.entry("Sell", direction = strategy.short)

// Plot both moving averages for reference.
plot(fastMA, "Fast MA", color.aqua)
plot(slowMA, "Slow MA", color.orange)
```

Pine computes `ta.sma(close, lengthInput)` where it is written. Taji makes each `ta` handle once in `setup` and feeds it in `next`, on every bar and never under an `if`, because a bar a handle skips is a bar missing from its window. `color.aqua` and `color.orange` are `#00bcd4` and `#ff9800` in Taji's colour words.

The `varip` construct, from Pine's execution-model page:[^exec]

```pine
//@version=6
indicator("Executions on realtime bars demo")
//@variable Tracks the number of script executions, where 1 represents the first execution.
varip int executions = 0
// Add 1 to the `executions` value.
executions += 1
```

There is no Taji version of it. The nearest Taji counter counts bars, not executions, because each tick adds one to the count the last close committed:

```ts
// Taji
import { indicator, plot } from "@taji/indicators";

export default indicator({
  name: "Bars counted",
  pane: "own",
  plots: { count: plot.line({ title: "Bars" }) },
  setup: () => ({ count: 0 }),
  next(_bar, s) {
    s.count += 1;
    return { count: s.count };
  },
});
```

## State and history

**Pine has a history operator. Taji keeps history in state.**

1. In Pine, `x[k]` reads a series `k` bars back: up to 5,000 bars for most series and 10,000 for open, high, low, close and time. Pine sizes each buffer from the first 244 bars, `max_bars_back` sets it by hand, and reading past it on a realtime bar is runtime error RE10143.[^limits][^exec]
2. Pine's `var` initialises a variable once and keeps its value across bars.[^exec] In Taji every value that outlives a bar is a field of the state `setup` returns, which the kernel copies on every close and restores before every tick.
3. A Taji number is a plain JavaScript double, not a series, so there is no `x[1]`: keep `s.prev = x` at the end of `next`, or an array in state for a longer lookback. One mechanism covers ticks too, since the state is restored with everything else ([The indicator SDK](https://docs.taji.is/indicators/sdk.md#how-does-an-indicator-remember-the-last-bar)).
4. Pine's `ta` namespace holds many built-ins, `ta.sma`, `ta.crossover`, `ta.rsi` and `ta.highest` among them.[^strategies][^alerts][^profiling] Taji's `ta` holds seven: `sma`, `ema`, `rma`, `rsi`, `change`, `crossUp` and `crossDown`, the same Rust the built-in indicators run, so `ta.rsi(14)` gives the built-in RSI's numbers bit for bit. Every other function is written in state from its formula.

A highest high, kept as an array in state:

```ts
// Taji
import { indicator, input, plot } from "@taji/indicators";

export default indicator({
  name: "Highest high",
  pane: "price",
  inputs: { length: input.int(20, { min: 1 }) },
  plots: { highest: plot.step({ title: "Highest high" }) },
  setup: () => ({ highs: [] as number[] }),
  next(bar, s, { inputs }) {
    s.highs.push(bar.high);
    if (s.highs.length > inputs.length) s.highs.shift();
    return { highest: s.highs.length < inputs.length ? NaN : Math.max(...s.highs) };
  },
});
```

The state holds plain data and `ta` or drawing handles only: a function, a class instance, a `Map` or a `Date` is refused, because a copy that flattened it would lose it silently.

## Missing values

**In Taji the missing value is `NaN`, and a plot draws nothing for it.**

1. A plot whose `next` returns `NaN`, leaves its key out or returns something other than a number draws nothing on that bar, and is served as null. `undefined` and `null` are never the missing value.
2. A `ta` primitive answers `NaN` until it has enough bars, and `NaN` carries through arithmetic, so a warm-up needs no code of yours.
3. `series.na(x)`, `series.nz(x, y)` and `series.fixnan(x, prev)` test, fill and carry a missing value, with `prev` kept in state. The [porting guide](https://docs.taji.is/skill/references/pine.md#mapping) maps Pine's `na`, `nz` and `fixnan` to them.
4. `series.eq`, `ne`, `gt`, `ge`, `lt` and `le` treat two numbers within 1e-10 as equal, and every comparison with `NaN` is false except `ne`. JavaScript's own `==` and `<` stay exact: choose the comparison you mean ([The indicator SDK](https://docs.taji.is/indicators/sdk.md#what-is-a-missing-value)).

A level that holds the close of the last cross up until the next one:

```ts
// Taji
import { indicator, input, plot, series, ta } from "@taji/indicators";

export default indicator({
  name: "Last cross level",
  pane: "price",
  inputs: { length: input.int(20, { min: 2 }) },
  plots: {
    avg: plot.line({ title: "Average" }),
    level: plot.step({ title: "Close at the last cross up", color: "#089981" }),
  },
  setup: ({ inputs }) => ({ avg: ta.sma(inputs.length), up: ta.crossUp(), level: NaN }),
  next(bar, s) {
    const avg = s.avg.next(bar.close);
    const cross = s.up.next(bar.close, avg) ? bar.close : NaN;
    s.level = series.fixnan(cross, s.level);
    return { avg, level: s.level };
  },
});
```

## Inputs

**The same input kinds and dialog keys; Taji's declaration is also your agent's schema.**

1. Pine's inputs are `input.int`, `float`, `bool`, `color`, `string`, `text_area`, `timeframe`, `symbol`, `session`, `source`, `time`, `price` and `enum`, with `group`, `inline`, `tooltip`, `confirm`, `active` and `options`.[^inputs] Taji's are `input.int`, `float`, `bool`, `choice`, `text`, `color`, `session`, `interval`, `symbol`, `time`, `price`, `source` and `anchor`, taking the same option keys.
2. A Taji definition holds at most 32 inputs, and `confirm`, which asks you to click the chart as the indicator is added, works on `time` and `price` only.
3. The kernel turns the inputs into one JSON Schema. The window draws it as the settings dialog, and your agent reads it as the indicator's catalog row, so both offer the same choices within the same bounds. Each value is checked at write (the defaults) and at bind (the binding's values), naming the input that breaks a rule.
4. A `source` input is a bar field or another indicator's plot, and an `anchor` input says per bar whether a session, week, month or longer period starts, from the instrument's calendar. Both are per-bar values, read in `next`, never in `setup`.
5. The resolved inputs are part of the instance's key: two bindings with equal inputs on one series share one computation ([Inputs](https://docs.taji.is/indicators/inputs.md#what-does-one-setting-become)).

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

export default indicator({
  name: "Average of a source",
  pane: "price",
  inputs: {
    src: input.source("close", { title: "Source" }),
    kind: input.choice("ema", { options: ["sma", "ema", "rma"], title: "Average", group: "Average", inline: "avg" }),
    length: input.int(20, { min: 1, max: 500, title: "Length", group: "Average", inline: "avg" }),
  },
  plots: { avg: plot.line({ title: "Average" }) },
  setup: ({ inputs }) => ({ avg: ta[inputs.kind](inputs.length) }),
  next(_bar, s, { inputs }) {
    return { avg: s.avg.next(inputs.src) };
  },
});
```

A `choice` input types as the union of its options, so `ta[inputs.kind]` type-checks, and a misspelt option is an error in your editor before the write.

## Outputs

**Taji's drawing limits match Pine's; a definition serves 32 plot columns to Pine's 64.**

1. A Pine script has up to 64 plots, and one call can make up to 7 of them.[^limits] A Taji definition serves up to 32 columns, a candle or bar counting four, and 16 fills.
2. Pine draws up to 500 lines, boxes and labels and 100 polylines, 50 of each by default, deleting the oldest past the cap; a polyline holds up to 10,000 points.[^limits][^lines] Taji's caps are the same numbers, set with `max_lines`, `max_labels`, `max_boxes` and `max_polylines`: a kind holds up to its cap plus 5, then deletes its oldest down to the cap.
3. With `xloc.bar_index`, Pine draws from 10,000 bars back to 500 forward.[^limits] Taji's bar-index reach is the same; `xloc: "bar_time"` places an x at any instant.
4. Pine allows 9 tables, one per chart position, a new one taking the place of the last.[^limits][^debug] Taji holds one table or card per position, the newest winning, a table 1 to 20 columns by 1 to 100 rows.
5. A Taji colour is one of three: a fixed colour, a palette of 1 to 8 whose slot `next` returns per bar, or a colour computed per bar. A palette keeps what the script decides (which slot) apart from how it looks (the colours), so a binding's style can recolour it without recomputing.
6. Every Taji output is a column the kernel serves: the window draws it, your agent reads the same rows with `GET /get/indicators`, and an alert compares one plot ([Outputs](https://docs.taji.is/indicators/outputs.md#who-reads-the-outputs)).

```ts
// Taji
import { fill, indicator, input, label, plot, ta } from "@taji/indicators";

export default indicator({
  name: "RSI zones",
  pane: "own",
  inputs: { length: input.int(14, { min: 2 }) },
  plots: {
    rsi: plot.line({ title: "RSI", colors: ["#f23645", "#787b86", "#089981"] }),
    bounds: plot.levels([30, 70]),
  },
  fills: { band: fill(70, 30, { color: "#7e57c2", alpha: 0.1 }) },
  max_labels: 20,
  setup: ({ inputs }) => ({ rsi: ta.rsi(inputs.length), over: ta.crossUp() }),
  next(bar, s, { ctx }) {
    const rsi = s.rsi.next(bar.close);
    if (s.over.next(rsi, 70)) label.new({ x: ctx.index, y: rsi, text: "70" });
    const slot = rsi > 70 ? 0 : rsi < 30 ? 2 : 1;
    return { rsi, colors: { rsi: slot } };
  },
});
```

**Alerts are outside the script.** Pine has `alertcondition()` in indicators and `alert()` with a message built per bar, and its alerts run around the clock on TradingView's servers from a saved copy of the script and its inputs.[^alerts] A Taji script has no alert call: you bind it, then add an alert whose operand is one of its plots. The alert pins the indicator's version (`name@N`), reads the chart's own instance where the desk shows it, and fires with the desk off screen, in your kernel.

## Other data

**Pine requests other data in the script body; Taji declares it before the first bar.**

1. Pine's `request.*()` functions are calls in the script.[^otf] A Taji script names every other series in `data`, so the kernel fetches it, computes it once for every reader of that series and aligns it to your bars by the instrument's calendar before `next` first runs. No call inside `next` fetches anything.
2. `data` may be a function of the inputs, so an interval can be a setting: `data: ({ inputs }) => ({ htf: data.bars({ interval: inputs.tf }) })`.
3. A higher interval gives `.last` and `.changed`, and `depth` adds `.at(k)` up to 500 bars back. A finer interval gives `.intrabars`. Events give `.last` and `.changed`. Every read is as of this bar's close.
4. A frozen pane is never fed, so a script with `data` faults there ([Inputs](https://docs.taji.is/indicators/inputs.md#what-can-an-indicator-not-read)).

Pine reads three kinds of data that an indicator does not take as an input ([Inputs](https://docs.taji.is/indicators/inputs.md#what-can-an-indicator-not-read)):

| Reads | Taji | Pine |
|---|---|---|
| Financial statements | Not an input | `request.financial()`, FactSet data[^otf] |
| Economic series | Not an input | `request.economic()`[^otf] |
| Currency conversion | Not an input | `request.currency_rate()`[^otf] |

```ts
// Taji
import { data, indicator, plot } from "@taji/indicators";

export default indicator({
  name: "Daily close and dividends",
  pane: "price",
  data: { day: data.bars({ interval: "D" }), divs: data.events("dividends") },
  plots: {
    daily: plot.step({ title: "Last daily close" }),
    ex_date: plot.marker({ shape: "circle", at: "above" }),
  },
  setup: () => ({}),
  next(bar, _s, { data }) {
    return {
      daily: data.day.last.close,
      ex_date: data.divs.changed ? bar.high : NaN,
    };
  },
});
```

## Repainting

**Pine's lookahead is an argument; Taji has none to set.**

1. `request.security()` defaults to `lookahead_off`. With `lookahead_on` and no historical offset, history sees higher-timeframe values before they happened, realtime values can then repaint after a reload, and such scripts cannot be published. `close[1]` with `lookahead_on` is the form the manual recommends.[^otf]
2. Every Taji read is as of this bar's close. `asof: "open"` moves the cut to this bar's open, the documented counterpart of `expr[1]` with `lookahead_on`; the counterpart of `lookahead_on` with no offset is not built, because it reads the future.
3. Two Taji reads can repaint, and each marks the binding `repaints` in its served metadata: `data.<n>.forming`, the higher bar still in progress, and `calc` with `calc_closes` off ([Execution](https://docs.taji.is/indicators/execution.md#which-indicators-repaint)).
4. A closed bar's Taji value changes only when its instance recomputes from its first bar: after a backfill, a restated bar or an out-of-order event.

A daily close with no lookahead. The Pine is a minimal form of the pattern on the manual's page, not a verbatim copy:[^otf]

```ts tab={"label":"Taji"}
// Taji
import { data, indicator, plot } from "@taji/indicators";

export default indicator({
  name: "Daily close, no lookahead",
  pane: "price",
  data: { d: data.bars({ interval: "D", asof: "open" }) },
  plots: { daily: plot.line({ title: "Daily close", color: "#089981", width: 2 }) },
  setup: () => ({}),
  next(_bar, _s, { data }) {
    return { daily: data.d.last.close };
  },
});
```

```pine tab={"label":"Pine"}
//@version=6
indicator("HTF close demo", overlay = true)
float dailyClose = request.security(syminfo.tickerid, "1D", close[1], lookahead = barmerge.lookahead_on)
plot(dailyClose, "Daily close", color.teal, 2)
```

The Taji version declares the daily series in `data`, so there is no call inside the bar loop and no `lookahead` argument to get wrong.

## Testing

**Every Taji write is tested before it is stored, and may carry tests of its own.**

1. The kernel compiles the source, runs it over a fixed fixture of 1,024 bars and checks three invariants: a second run gives bitwise the same rows (determinism), the first half of the history equals the first half of the whole (prefix), and ticks of a bar followed by its close give the close alone (ticks then close). A failure names the first differing row, and nothing is stored ([Execution](https://docs.taji.is/indicators/execution.md#what-does-a-write-check)).
2. A write may carry a `test`: a module whose default export maps names to functions of `t`. `t.run(params, closes)` runs the indicator over bars made from closes, and `t.assert` and `t.near` check the rows. `indicators/test` reruns the stored test; `indicators/check` runs every check without storing.
3. Pine's debugging tools are logs and a profiler: `log.info()`, `log.warning()` and `log.error()` write to the Pine Logs pane for personal scripts, keeping the most recent 10,000 historical entries, and the Pine Profiler times each line.[^debug][^profiling] Taji's `log(message)` keeps a line only on a close and shows the newest 200 in the write's report; a fault names its bar, line and column. Taji has no profiler.

A test for the highest high above, stored beside its source:

```ts
// Taji
import type { T } from "@taji/indicators";

export default {
  "the highest of the last three bars"(t: T) {
    const r = t.run({ length: 3 }, [1, 5, 2, 3, 4, 1]);
    t.assert(r.highest[1] !== r.highest[1], "missing before the third bar");
    t.assert(r.highest[3] === 5, "5 is still in the window");
    t.assert(r.highest[4] === 4, "5 has left it");
  },
};
```

## Summary

| | Taji | Pine |
|---|---|---|
| Language | TypeScript, types stripped and run in V8 | Pine Script v6, TradingView's own[^welcome] |
| Where it runs | The kernel on your machine | TradingView's servers[^welcome] |
| Who writes it | Your agent, type-checked against `taji.d.ts` before the write | You, in the Pine Editor;[^first] or an agent through TradingView's MCP server[^mcp] |
| Per bar | `setup` once, `next` per bar and per tick | The whole script, then again per tick[^exec] |
| Tick rollback | Yes, always | Yes; `varip` escapes it[^exec] |
| History | State: `s.prev`, arrays; `depth` up to 500 on `data` | `x[k]`, up to 5,000 bars (10,000 for OHLC and time)[^limits] |
| `ta` | Seven primitives, the built-ins' own code | Many built-ins[^strategies] |
| Other data | `data`: other intervals and symbols, intrabars, events, hub and plugin products | `request.*`: other intervals and symbols, intrabars, events, financials, economic, seed, footprint;[^otf][^limits] `bid`, `ask` and `aggressor_side` on 1-tick charts[^release] |
| Extensions | Plugins: verbs and nodes, data sources and products, panes, chart layers and indicators of their own | Libraries[^libraries] |
| Lookahead | None; `asof: "open"` for the bar before | An argument, off by default[^otf] |
| Inputs | 13 kinds, at most 32, one schema for dialog and agent | 13 kinds[^inputs] |
| Plots | 32 columns, 16 fills | 64[^limits] |
| Drawings | 500 lines, labels, boxes; 100 polylines | 500 lines, labels, boxes; 100 polylines[^limits] |
| Tables | One table or card per position | 9, one per position[^limits] |
| Alerts | Outside the script, on a plot, version pinned, in your kernel | `alertcondition()`, `alert()`, on TradingView's servers[^alerts] |
| Strategies | None | `strategy()` and its strategy report[^strategies] |
| Libraries | One file; scripts compose through `source` inputs | `library()` and `import`[^libraries] |
| Checks before it runs | The compiler, three invariants and your own tests, on every write | The compiler[^mcp] |
| Debugging | `log` on closes, faults with bar, line and column | Pine Logs and the Pine Profiler[^debug][^profiling] |
| CPU limits | Compile, history or test 1 s; `setup`, tick or close 50 ms | Compile 2 minutes; 500 ms per loop per bar[^limits] |
| Memory and size | 256 MB heap; source 256 KiB | 100,256 compiled tokens; 100,000 collection elements[^limits] |
| Versions | Every write a version, `name@N`; bindings and alerts pin | Libraries pinned by importers; published history[^libraries][^publishing] |

## Bring your Pine scripts

Your agent ports a Pine indicator by the skill's [porting guide](https://docs.taji.is/skill/references/pine.md): it reads the script whole, stops and tells you if it uses a construct Taji does not port (`varip`, `strategy.*`, libraries, `request.financial` and the others it lists), maps each line, writes the indicator with a test, binds it and reads the last rows back for you to set beside your TradingView chart. The guide holds every mapping row, from `close[1]` to `table.new`; this page repeats none of them.

A ribbon of three exponential moving averages with the outer two shaded between, in each, written for this page. The Taji file is whole as it stands:

```ts tab={"label":"Taji"} file="examples/pine-port/ema_ribbon.ts" title="ema_ribbon.ts"
import { fill, indicator, input, plot, ta } from "@taji/indicators";

export default indicator({
  name: "EMA Ribbon",
  pane: "price",
  inputs: {
    fast_length: input.int(8, { min: 2, title: "Fast length" }),
    mid_length: input.int(21, { min: 2, title: "Middle length" }),
    slow_length: input.int(55, { min: 2, title: "Slow length" }),
  },
  plots: {
    fast: plot.line({ title: "Fast", color: "#00bcd4" }),
    mid: plot.line({ title: "Middle", color: "#ff9800" }),
    slow: plot.line({ title: "Slow", color: "#9c27b0" }),
  },
  fills: { ribbon: fill("fast", "slow", { color: "#2962ff", alpha: 0.15 }) },
  setup: ({ inputs }) => ({
    fast: ta.ema(inputs.fast_length),
    mid: ta.ema(inputs.mid_length),
    slow: ta.ema(inputs.slow_length),
  }),
  next(bar, s) {
    return { fast: s.fast.next(bar.close), mid: s.mid.next(bar.close), slow: s.slow.next(bar.close) };
  },
});
```

```pine tab={"label":"Pine"}
//@version=6
indicator("EMA Ribbon", overlay = true)
int fast_length = input.int(8, "Fast length", minval = 2)
int mid_length = input.int(21, "Middle length", minval = 2)
int slow_length = input.int(55, "Slow length", minval = 2)
float fast = ta.ema(close, fast_length)
float mid = ta.ema(close, mid_length)
float slow = ta.ema(close, slow_length)
fast_plot = plot(fast, "Fast", color.aqua)
plot(mid, "Middle", color.orange)
slow_plot = plot(slow, "Slow", color.purple)
fill(fast_plot, slow_plot, color.new(color.blue, 85))
```

![The EMA Ribbon on a daily SPY chart: three moving averages, the outer two shaded between](https://raw.githubusercontent.com/TajiAI/Taji/main/docs/indicators/examples/pine-port/shot.png)

The Pine `indicator(..., overlay = true)` line became `name` and `pane: "price"`; each `input.int` line became an entry of `inputs`; each `ta.ema(close, n)` line became a `ta.ema(n)` in `setup` and its `.next(bar.close)` in `next`; each `plot` line became an entry of `plots`; and `fill(fast_plot, slow_plot, color.new(color.blue, 85))` became `fills: { ribbon: fill("fast", "slow", { color: "#2962ff", alpha: 0.15 }) }`, where `alpha` is 1 minus the transparency over 100.

The kernel's last ten rows of the ribbon, newest last:

```json file="examples/pine-port/ema_ribbon.json"
[
  {
    "start_dt": "2026-11-19T00:00:00+00:00",
    "fast": 132.24455713364225,
    "mid": 131.07414366320012,
    "slow": 128.294531303195
  },
  {
    "start_dt": "2026-11-20T00:00:00+00:00",
    "fast": 132.93909999283287,
    "mid": 131.46467605745465,
    "slow": 128.54722661379517
  },
  {
    "start_dt": "2026-11-23T00:00:00+00:00",
    "fast": 133.78818888331446,
    "mid": 131.9460691431406,
    "slow": 128.84053994901677
  },
  {
    "start_dt": "2026-11-24T00:00:00+00:00",
    "fast": 134.57303579813347,
    "mid": 132.434608311946,
    "slow": 129.14337780798047
  },
  {
    "start_dt": "2026-11-25T00:00:00+00:00",
    "fast": 135.67458339854826,
    "mid": 133.0796439199509,
    "slow": 129.5143286005526
  },
  {
    "start_dt": "2026-11-27T00:00:00+00:00",
    "fast": 136.52689819887087,
    "mid": 133.66422174540992,
    "slow": 129.87131686481857
  },
  {
    "start_dt": "2026-11-30T00:00:00+00:00",
    "fast": 137.28314304356624,
    "mid": 134.23383795037265,
    "slow": 130.2305555482179
  },
  {
    "start_dt": "2026-12-01T00:00:00+00:00",
    "fast": 137.98022236721818,
    "mid": 134.79621631852058,
    "slow": 130.59446427863867
  },
  {
    "start_dt": "2026-12-02T00:00:00+00:00",
    "fast": 138.69350628561415,
    "mid": 135.37746938047326,
    "slow": 130.9728762686873
  },
  {
    "start_dt": "2026-12-03T00:00:00+00:00",
    "fast": 139.56606044436657,
    "mid": 136.0358812549757,
    "slow": 131.38884497337702
  }
]
```

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

## See also

- [Indicators](https://docs.taji.is/indicators.md), the model and the life of an indicator.
- [Your first indicator](https://docs.taji.is/indicators/first-indicator.md), write, bind and test one yourself.
- [The indicator reference](https://docs.taji.is/skill/references/indicators.md), every field, kind, default and limit.
- [Plugins](https://docs.taji.is/plugins.md), what a plugin is and which kind you need.

[^welcome]: [Welcome to Pine Script v6](https://www.tradingview.com/pine-script-docs/welcome/), fetched 2026-12-03.
[^release]: [Release notes](https://www.tradingview.com/pine-script-docs/release-notes/), fetched 2026-12-03.
[^exec]: [Execution model](https://www.tradingview.com/pine-script-docs/language/execution-model/), fetched 2026-12-03.
[^limits]: [Limitations](https://www.tradingview.com/pine-script-docs/writing/limitations/), fetched 2026-12-03.
[^otf]: [Other timeframes and data](https://www.tradingview.com/pine-script-docs/concepts/other-timeframes-and-data/), fetched 2026-12-03.
[^inputs]: [Inputs](https://www.tradingview.com/pine-script-docs/concepts/inputs/), fetched 2026-12-03.
[^strategies]: [Strategies](https://www.tradingview.com/pine-script-docs/concepts/strategies/), fetched 2026-12-03.
[^alerts]: [Alerts](https://www.tradingview.com/pine-script-docs/concepts/alerts/), fetched 2026-12-03.
[^libraries]: [Libraries](https://www.tradingview.com/pine-script-docs/concepts/libraries/), fetched 2026-12-03.
[^lines]: [Lines and boxes](https://www.tradingview.com/pine-script-docs/visuals/lines-and-boxes/), fetched 2026-12-03.
[^debug]: [Debugging](https://www.tradingview.com/pine-script-docs/writing/debugging/), fetched 2026-12-03.
[^profiling]: [Profiling and optimization](https://www.tradingview.com/pine-script-docs/writing/profiling-and-optimization/), fetched 2026-12-03.
[^publishing]: [Publishing scripts](https://www.tradingview.com/pine-script-docs/writing/publishing/), fetched 2026-12-03.
[^structure]: [Script structure](https://www.tradingview.com/pine-script-docs/language/script-structure/), fetched 2026-12-03.
[^ticks]: [What are tick-based intervals for?](https://www.tradingview.com/support/solutions/43000709225-what-are-tick-based-intervals-for/), TradingView help center, fetched 2026-12-03.
[^first]: [First indicator](https://www.tradingview.com/pine-script-docs/primer/first-indicator/), fetched 2026-12-03.
[^mcp]: [TradingView MCP: Pine Script and daily limits](https://www.tradingview.com/blog/en/tradingview-mcp-pine-script-and-daily-limits-62532/), TradingView blog, fetched 2026-12-03.
