Series API
Every Series (close, a ta.* result, an input.source) has these members.
s[n]Value n bars back, current-first: s[0] is the newest bar, s[1] the bar before. NaN when there is no such bar yet.
Returnsnumber
const prevClose = close[1];valueThe newest bar's value. Same as s[0] and s.at(0).
Returnsnumber
at(n = 0)Same as s[n]: the value n bars back.
Returnsnumber
offset(n)The whole Series shifted n bars back: Pine's s[n] as a Series you can plot or compare.
ReturnsSeries
const rising = ma.gt(ma.offset(1));add(x) / sub(x) / mul(x) / div(x) / mod(x)Bar-by-bar math. x can be a Series or a number.
ReturnsSeries
const mid = high.add(low).div(2);neg() / abs()Negate, absolute value.
ReturnsSeries
gt(x) / lt(x) / gte(x) / lte(x) / eq(x) / ne(x)Comparisons. Each bar is 1 (true) or 0 (false), ready for plotShape, bgColor or barColor.
ReturnsSeries
and(x) / or(x) / not()Combine 1/0 conditions bar by bar.
ReturnsSeries
iff(then, otherwise)Per-bar ternary: where this Series is true use then, else otherwise (Pine's cond ? a : b).
ReturnsSeries
column()The full history as a plain array, current-first (index 0 = newest bar).
Returnsnumber[]
makeSeries(() => column)Build your own Series from a function that returns a current-first array. Use it for logic no ta.* function covers.
ReturnsSeries