Skip to main content

What is a Series?

A Series is a named array that grows bar by bar. You write a value at the current bar with .set() and read past values with .get(offset). Unlike regular JavaScript variables that reset on each onBar call, a Series persists across bars.

API reference

Series object
Create a named series. Must be called at the top level (not inside onBar). Up to 64 series per script.
void
Store value at the current bar index. Call inside onBar.
number
Number of bars where .set() has been called.

Budget

  • Maximum 64 Series per script (shared with any hidden series created internally by ta.barssince and ta.cum).
  • Each series consumes roughly 8 KB per bar in the window.
  • Total budget across all series: ~512 KB per script.
Creating Series inside onBar mid-execution is allowed syntactically, but the series will have no backfill - it starts empty from the bar it was first created. For correct historical replay, always create Series at the top level.

Worked example: crossover detection

No-backfill behavior

A Series created mid-script (e.g. inside a conditional block on bar 500) has no values for bars 0-499. s.get(offset) returns NaN for those bars. Plan accordingly using na(s.get(...)) guards.

NaN handling

Series.get() returns NaN during warmup.

Aggregators

ta.barssince and ta.cum use internal series with a key.

API limits

64-series budget shared with stateful aggregators.