Core Concepts
Bars, series, scripts, the execution model and the vocabulary used throughout the docs.
A bar is one interval of price action: time, open, high, low, close, volume. Bars arrive oldest first and are immutable once closed. The bar currently forming is called provisional — its close moves with every tick, so any value derived from it can change until the interval ends. Most surprises in systematic trading come from forgetting that distinction.
A series is a value computed for every bar, indexed backwards. Writing close gives you the current close, close[1] the previous one, close[20] the close twenty bars ago. Indicators are just series built from other series, which is why ta.ema(ta.rsi(close, 14), 5) is a legal expression: the RSI is a series, and the EMA smooths it exactly the way it would smooth price.
A script is a file that declares inputs, computes series, and emits output — plots, fills, labels, alerts, and in the case of a strategy, orders. Scripts are evaluated once per bar, from the first bar to the last. They cannot look forward, cannot read the file system, and cannot reach the network. That sandbox is what makes a script portable between the hosted charts and a server process.
Execution is bar-by-bar and single-threaded. On historical data the runtime replays every bar in order and never revisits one; on live data it evaluates the provisional bar on each update and then commits when the bar closes. A strategy therefore sees exactly what a trader watching the chart would have seen at that moment, which is the whole point of the model.
Two more terms recur in these pages. A provider is the thing that supplies bars. A report is what a backtest returns: statistics, a trade list and an equity curve. Everything else is built out of those five nouns.