The series data type
Most Pine values are series — values that change bar by bar across chart history. When you write close, Pine implicitly refers to the close of every bar on the chart, past and future. When you write close - close[1], you get the bar-over-bar change for every bar.
This is the single most important idea in Pine. It is what lets you write plot(close > close[1]) instead of looping over every bar in Python. Pine does that loop for you.
Simple types: int, float, bool, string, color
Pine has five primitive types: int, float, bool, string, color. A series of floats is what close is. A series of bools is what close > close[1] returns. A series of colors is what you pass to plot.
History references: [1], [2], [n]
Square brackets look up past bars. close[1] is the close one bar ago. close[20] is the close 20 bars ago. close[0] is the current bar (same as close). Reading history is the basic building block of every indicator.
na: Pine's "no value"
na means "no value". The first 20 bars of a 20-period moving average are na because there isn't enough history yet. Most plots handle na gracefully by leaving gaps on the chart, but be careful when doing math — close + na is na, not close.
Type mismatch errors
If you write plot(close > close[1]) you cannot plot a bool as a line — Pine will throw a type error. Either cast to a number (plot(close > close[1] ? 1 : 0)) or use plotshape / plotchar for booleans.
Why this matters
Every script you write is a vectorised operation across chart history. Once that clicks, the rest of Pine is just syntax.