What is a Series?
ASeries 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
Create a named series. Must be called at the top level (not inside
onBar). Up to 64 series per script.Store
value at the current bar index. Call inside onBar.Read the value at
offset bars back. offset = 0 (default) is the current bar. Returns NaN for bars where .set() was never called.Number of bars where
.set() has been called.Budget
- Maximum 64 Series per script (shared with any hidden series created internally by
ta.barssinceandta.cum). - Each series consumes roughly 8 KB per bar in the window.
- Total budget across all series: ~512 KB per script.
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.
Related pages
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.