1

So I am getting the following undeclared identifier error on Pine Editor regarding the colors..

line 23: Undeclared identifier 'red';
line 24: Undeclared identifier 'blue';
line 25: Undeclared identifier 'white';
line 36: Undeclared identifier 'blue';
line 36: Undeclared identifier 'white';
line 50: Undeclared identifier 'red';
line 50: Undeclared identifier 'black'

And here is the code I'm running. As you can see I'm running version 4.

//@version=4
 study("Simple Trading", overlay = true)
 
ma5 = sma(close, 5)
ma10 = sma(close, 10)
ma30 = sma(close, 30)
 
src1 = input(close, title = "RSI Source")
rsil = input(14, minval = 1, title = "RSI Length")
rsi30 = input(30, minval = 1, title = "Buy w/RSI < ")
rsi70 = input(70, minval = 1, title = "Sell w/RSI > ")
 
src2 = input(close, title = "Stoch Source")
kdk = input(9, minval = 1, title = "Stoch K")
kdd = input(3, minval = 1, title = "Stoch D")
kds = input(3, minval = 1, title = "Stoch Smooth")
kd20 = input(20, minval = 1, title = "Buy w/STOCH <")
kd80 = input(80, minval = 1, title = "Sell w/STOCH >")
 
plot(ma5, color = red)
plot(ma10, color = blue)
plot(ma30, color = white)
 
//main------------------------------------
_falling = falling(ma30, 20)
fiveless = ma5 < ma30
tenless = ma10 < ma30
armbuy = fiveless and tenless and _falling
rsi = rsi(src1, rsil) < rsi30
greencandle = close > open and close[1] <= open[1] and close>close[1]
strongbuyhere = armbuy and rsi and greencandle
 
plotshape(strongbuyhere, style = shape.labelup, color = blue, location = location.belowbar, size = size.small, text = "Buy", textcolor = white)
alertcondition(strongbuyhere, title = "Strong Buy Position", message = "Buy")
plot(valuewhen(strongbuyhere, close, 0))
 
 
//reverse---------------------------------
r_falling = rising(ma30, 20)
rfiveless = ma5 > ma30
rtenless = ma10 > ma30
rarmbuy = rfiveless and rtenless and r_falling
rrsi = rsi(src1, rsil) > rsi70
rgreencandle = close < open and close[1] > open[1]
rstrongbuyhere = rarmbuy and rrsi and rgreencandle
 
plotshape(rstrongbuyhere, style = shape.labeldown, color = red, location = location.abovebar, size = size.small, text = "Sell", textcolor = black)
alertcondition(rstrongbuyhere, title = "Strong Sell Position", message = "Sell")
plot(valuewhen(rstrongbuyhere, close, 0))''' 

Does anyone know how I can fix this and what I have done wrong?

Thanks

asked Oct 12, 2020 at 11:30

1 Answer 1

2

You are using the pinescript version 4 (line 1: //@version=4). In version 4 colors are named with the color. prefix:

ex https://www.tradingview.com/pine-script-reference/#var_color{dot}red :

color.red
color.blue
color.black

or color.new function https://www.tradingview.com/pine-script-reference/#fun_color{dot}new

answered Oct 12, 2020 at 11:47
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.