Pine Script – Undeclared identifier ‘green’ / ‘’ – how to fix it?

You might see the following error in Pine Script quite often, especially if you’re trying to merge a few scripts or copy certain elements from another script. You might see this error with basically all supported colors:

Undeclared identifier ``
Undeclared identifier ``
Undeclared identifier `color.white`
Undeclared identifier 'red'
Undeclared identifier 'black'
Undeclared identifier 'white'

If you see one of these errors, then you have a conflict with Pine Script versions. When Pine Script was updated from v3 to v4, quite a lot of keywords were renamed and colors as well. In v4 and v5, you have to use colors with the prefix “color.”. You can use the following table to see the changes made to built-in color vars:

V3 and beforeV4 and above
fuchsia color.fuchsia
gray color.gray
lime color.lime
maroon color.maroon
olive color.olive
purple color.purple
silver color.silver
teal color.teal
white color.white
yellow color.yellow

So simply pick the correct variable for your version of Pine Script, and it will be fixed. For example the following will work in v3 and below:

study("My script")
plot(close, color = black)

And the following code works for the v4 and above:

study("My script")
plot(close, color =

Follow me on TradingView and YouTube.

This image has an empty alt attribute; its file name is wide.png

Leave a Comment

Your email address will not be published. Required fields are marked *

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.