◆ New — Strategy Validator, Code Fixer & Prop Compliance Checker are live. Try one free →
Error reference · Pine v6

Pine Script errors, decoded.

The errors TradingView throws when a script won't compile — each one explained, with the cause and the exact fix in validated before/after code.

Scope
Undeclared identifier '<name>'
Pine v6 raises "Undeclared identifier" when you reference a variable or function name the compiler has never seen at that point — usually a typo, a wrong namespace, or use-before-declaration.
Cannot use 'plot' in local scope
plot(), and the declaration-style calls like indicator()/strategy()/plotshape()/alertcondition(), must live at the script's main scope — never inside an if, for, or function body.
The function 'ta.ema' should be called on each calculation for consistency. It is recommended to extract the call from this scope.
A stateful ta.
Syntax
Mismatched input '<end of line>' expecting '<statement>'
This parser error means a line ended where Pine still expected more code — almost always broken indentation or an incomplete multi-line statement.
Syntax error at input 'end of line without line continuation'
Pine expected a wrapped statement to continue on the next line but the indentation broke the continuation, so it read a premature line end.
Namespace/v6
Could not find function or function reference 'study'
In v6 study() no longer exists — it was renamed indicator() — and most built-ins now live under namespaces (ta.
Types
Add to Chart operation failed, reason: line N: Cannot call 'operator +' with argument of type 'series string'
This runtime type error means you tried to + a non-string value onto a string without converting it first — Pine's + does not auto-cast numbers to text.
Cannot call 'ta.sma' with argument 'length'='series int'. The argument 'length' of 'ta.sma' should be of type 'simple int'.
You passed a series int where ta.
Limits
line N: Script requesting too many securities. The limit is 40.
Your script triggers more than the allowed number of unique request.
Loop is too long (> 500 ms).
A single execution of a loop exceeded Pine's 500 ms per-bar time budget, usually from an unbounded or very large iteration count.
Series/history
Pine cannot determine the referencing length of a series. Try using max_bars_back in the study or strategy function.
Pine could not statically infer how far back a series is referenced, usually because the history access happens inside a conditional branch.
The requested historical offset (N) is beyond the historical buffer's limit (M).
The script asked for a past value further back than the historical buffer allocated for that series, raising a runtime error.

Educational reference only — not financial advice. Trading involves substantial risk of loss.

Catch the bug that compiles.Run auditGet Pro