Edgoro
Pine Script errors

Pine Script errors: causes and fixes

The messages TradingView prints in the Pine Editor console, what each one means, and the change that fixes it. Every page has a short script that triggers the error and the corrected Pine Script v6 version.

Syntax and indentation

The compiler can't read the code: indentation, wrapped lines, stray characters, names it doesn't know.

Types and qualifiers

A value of the wrong type, or a value that changes on every bar where Pine needs one that stays fixed (series, simple, input, const).

series int used but simple int expected

Cannot call "ta.ema" with argument "length"="len". An argument of "series int" type was used but a "simple int" is expected.

Compile error · Cause and fix

hline(): series float used but input float expected

Cannot call "hline" with argument "price"="call "ta.sma" (series float)". An argument of "series float" type was used but a "input float" is expected.

Compile error · Cause and fix

series string used but const string expected

Cannot call "plotshape" with argument "text"="call "str.tostring" (series string)". An argument of "series string" type was used but a "const string" is expected.

Compile error · Cause and fix

Value with NA type cannot be assigned

Value with NA type cannot be assigned to a variable that was defined without type keyword

Compile error · Cause and fix

Return type of if/switch blocks not compatible

Return type of one of the "if" or "switch" blocks is not compatible with return type of other block(s) (literal string; literal int)

Compile error · Cause and fix

Cannot assign a value of another type

Cannot assign a value of the "string" type to the "level" variable. The variable is declared with the "float" type.

Compile error · Cause and fix

simple variable cannot accept a series value

A variable declared with the "simple" keyword cannot accept values of the "series int" form. Assign a "simple" value to this variable or remove the "simple" keyword from its declaration.

Compile error · Cause and fix

Cannot call operator + with a string and a number

Cannot call "operator +" with argument "expr0"="Close: ". An argument of "literal string" type was used but a "series float" is expected.

Compile error · Cause and fix

Scope

Code in the wrong place: plots inside blocks, functions that change globals, calls that skip bars.

Old code in v6 (v4 and v5 to v6)

Functions and arguments that were renamed or removed, and the stricter bool rules of Pine Script v6.

Runtime limits

The script compiles but stops on the chart: loop time, history buffers, data requests, array bounds.

Compile errors and warnings were reproduced with TradingView's Pine Script compiler, and every fixed script compiles in Pine Script v6. Runtime errors only appear on the chart; those pages follow TradingView's documentation.

Error not listed here?

Paste your script and the message into the free error fixer, or describe the indicator in plain English and let Edgoro write working Pine Script v6.