> ## Documentation Index
> Fetch the complete documentation index at: https://docs.0xarchive.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Missing values

> How na works, and how to keep a script correct where data is missing.

Handle data that is not there. A missing number is `na`, a float NaN, as in Pine; missing strings, colours and objects are `null`.

* Arithmetic with `na` gives `na`, and every comparison with it is false, including `na === na`.
* `isNa(x)` tests for it; `nz(x, replacement)` replaces it, with 0 by default.
* A plot set to `na` draws nothing on that bar: a line breaks there unless it says `join: true`.
* An indicator updated with `na` follows TradingView's rule for that indicator.

Because comparisons with `na` are false, test for the condition you want rather than its opposite:

```ts theme={"theme":"github-dark"}
// Draws nothing until the EMA has a value, then colours each bar.
const value = ema.update(chart.close);
if (!isNa(value)) line.set(value, chart.close > value ? color.up : color.down);
```

## Missing strings, colours and objects

Anything that is not a number is `null` when it is missing: a market input left on the chart's own, a colour input that follows the theme, the wallet on a Lighter liquidation. Check before using one, as for any nullable value in TypeScript:

```ts theme={"theme":"github-dark"}
liq.onLiquidation((l) => {
  if (l.user === null) return;
  seen.set(l.user, (seen.get(l.user) ?? 0) + l.notional);
});
```

A colour of `null` passed to a plot's `set` means the plot's own colour, not none; use `color.none` to draw nothing on that bar.

## In state and history

A series bar that was never set reads `na`, and so does `ago(n)` before the first bar. A `state.bar(na)` cell is a common way to mean "not known yet": the first bar that knows the value writes it, and every bar after reads it.

```ts theme={"theme":"github-dark"}
const firstClose = state.bar(na);

chart.onBar(() => {
  if (isNa(firstClose.value)) firstClose.value = chart.close;
  change.set(chart.close / firstClose.value - 1);
});
```

## Where data starts

Each stream has a start: trades the start of the UTC day before yesterday, liquidations 7 days back, the order book 2026-03-10. Before it, a stream's `available` is false and its values are `na`. Check `available` before using a stream, so older bars stay empty instead of showing zeros:

```ts theme={"theme":"github-dark"}
chart.onBar(() => {
  if (!tape.available) return;
  deltaBars.set(delta.value);
});
```

## Next step

Bring scripts from TradingView with [Pine Script](/terminal/guides/pine).


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.