Real built-inPine Script v6

Syntax error at input "color"

color is a reserved type keyword — you cannot use it as a variable or parameter name.

Quick answer

color is a reserved type keyword in Pine Script, so you cannot use it as a variable name or a function parameter. Writing color = close > open ? color.green : color.red produces "Syntax error at input 'color'". The fix is a rename — use barColor, lineColor or plotColor. The same trap applies to the other type keywords: int, float, bool, string, label, line, box, table, array and matrix are all reserved and produce the same error with their own name in the message.

The exact error

Syntax error at input "color"

v5 → v6

Applies to v4, v5 and v6. The reserved list grew as Pine added types — box, table and matrix became reserved in later versions, so a v4 script that used box as a variable name will hit this on migration even though it compiled before.

Why this happens

Pine reserves every type name as a keyword. color is both a type and a namespace (color.red, color.new), which is why using it as an identifier confuses the parser and produces a syntax error rather than a clearer message.

The error names the token the parser choked on, so "Syntax error at input 'color'" points at the exact word to rename. The same message appears with int, float, bool, string, label, line, box, table, array or matrix in place of color.

This is a very common mistake because color is the natural name for a colour variable. Prefix or suffix it instead: barColor, lineColor, plotColor, colorUp.

A second, less obvious cause of the same message is a v4-style positional call where v5 and v6 require a named argument. If renaming does not clear it, check whether the line uses the old positional form of a function whose signature changed.

Note that color.red, color.new() and color.rgb() are all fine — the restriction is on using the bare word color as an identifier you define.

The working code

//@version=6
syntax-error-at-input-color.pine
//@version=6
indicator("Naming around reserved keywords", overlay = true)

// WRONG - "color" is a reserved type keyword:
// color = close > open ? color.green : color.red     // Syntax error at input "color"

// RIGHT - rename the variable. The color.* namespace is still fine to use.
barColor = close > open ? color.green : color.red
plot(close, "Close", color = barColor)

// The same rule applies to the other type keywords. All of these are reserved:
// int, float, bool, string, color, label, line, box, table, array, matrix
lineWidth = input.int(2, "Line width", minval = 1)      // not "int"
isBull    = close > open                                 // not "bool"
plot(ta.ema(close, 20), "EMA", color = color.orange, linewidth = lineWidth)

Copy and paste into the TradingView Pine Editor, or let TradePilot adapt it to your exact case.

FAQ

Syntax error at input "color" — common questions

Why does Pine Script say "Syntax error at input color"?

Because color is a reserved type keyword and you used it as an identifier — usually as a variable name. Rename the variable to something like barColor or lineColor and the error clears.

Which words are reserved in Pine Script?

The type names: int, float, bool, string, color, label, line, box, table, array, matrix, plus language keywords such as if, for, while, var, varip, switch, import, export, method and type. None can be used as an identifier.

Can I still use color.red and color.new() after renaming?

Yes. The restriction is only on defining your own identifier called color. The built-in color.* namespace is unaffected and works normally.

My script used box as a variable name in v4 and now fails — why?

box became a reserved type keyword when Pine added box drawing objects. A v4 script that used it as a variable name no longer compiles. Rename it, for example to priceBox.

More Pine reference

Other functions and errors

Never hit this error again.

TradePilot writes Pine Script v6 that's verified to compile before it reaches you — and if your existing script has this error, Pine Studio fixes it, root cause and all, in one pass. Start with 7 days free on any plan; cancel any time before it ends.

7-day free trial · Cancel anytime · No charge until day 7