簡體   English   中英

為什么這段代碼不能在 Pine Script 中運行? “未聲明的標識符”錯誤

[英]Why won't this code run in Pine Script? “Undeclared identifier” error

因此,我在 Pine Editor 上收到以下有關顏色的未聲明標識符錯誤。

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'

這是我正在運行的代碼。 如您所見,我正在運行版本 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))''' 

有誰知道我該如何解決這個問題以及我做錯了什么?

謝謝

您正在使用 pinescript 版本 4(第 1 行: //@version=4 )。 在第 4 版中,顏色以顏色命名color. 字首:

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

color.red
color.blue
color.black

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM