Data Series

Built-in price data, time series, bar state, and symbol information

PineTS provides built-in data series that are available in every indicator without imports. These represent the current symbol's OHLCV data, time information, and bar state.

Price Data (OHLCV)

SeriesTypeDescription
openseries<number>Opening price of each bar
highseries<number>Highest price of each bar
lowseries<number>Lowest price of each bar
closeseries<number>Closing price of each bar
volumeseries<number>Trading volume of each bar

Computed Price Series

SeriesFormulaDescription
hl2(high + low) / 2Midpoint price
hlc3(high + low + close) / 3Typical price
ohlc4(open + high + low + close) / 4Average price
// Use any price series in calculations
const typicalPrice = hlc3;
const sma = ta.sma(typicalPrice, 20);
plot(sma, 'SMA of Typical Price');

Time Series

SeriesTypeDescription
openTimeseries<number>Bar open time in milliseconds
closeTimeseries<number>Bar close time in milliseconds

Bar Information

VariableTypeDescription
bar_indexseries<number>Index of the current bar (0-based)
last_bar_indexseries<number>Index of the final bar in the dataset
last_bar_timeseries<number>Timestamp of the final bar
// Only plot on the last 100 bars
if (bar_index > last_bar_index - 100) {
  plot(close, 'Recent Close');
}

Bar State

The barstate object provides flags about the current bar's position in the dataset:

PropertyTypeDescription
barstate.isfirstbooleanTrue on the first bar
barstate.islastbooleanTrue on the last bar
barstate.ishistorybooleanTrue for historical bars
barstate.isrealtimebooleanTrue for live/streaming bars
barstate.isnewbooleanTrue on the first tick of a new bar
barstate.isconfirmedbooleanTrue when the bar is confirmed (closed)
barstate.islastconfirmedhistorybooleanTrue on the last confirmed historical bar

Symbol Information

The syminfo object provides details about the current symbol:

PropertyDescription
syminfo.tickerSymbol name (e.g., "BTCUSDT")
syminfo.tickeridFull ticker ID
syminfo.descriptionSymbol description
syminfo.typeAsset type (e.g., "crypto", "stock")
syminfo.currencyQuote currency
syminfo.basecurrencyBase currency
syminfo.mintickMinimum price increment
syminfo.timezoneExchange timezone

Special Values

ValueDescription
naRepresents "not available" — similar to null. Use to check if a value exists
nz(value, replacement?)Returns replacement (default 0) if value is na
const prev = close[1];
// na check
if (!na(prev)) {
  const change = close - prev;
  plot(change, 'Change');
}

// nz shorthand — default to 0 if na
const safeChange = nz(close - close[1], 0);

Global Constants

NamespaceDescription
timeframeCurrent timeframe info (timeframe.period, timeframe.multiplier)
orderSort order constants (order.ascending, order.descending)
currencyCurrency code constants (59 currencies including currency.BTC, currency.USD)
displayDisplay mode constants
shapeShape type constants for plotshape()
locationLocation constants (location.abovebar, location.belowbar, etc.)
sizeSize constants (size.tiny, size.small, size.normal, size.large, size.huge)
formatFormat constants (format.price, format.volume, format.percent)
dayofweekDay-of-week constants

All data series support history access with bracket notation: close[1] returns the previous bar's close, close[10] returns 10 bars ago.