在 TradingView pine v4 中做一个指标

Doing an indicator in TradingView pine v4

我是新手,我正在做一些非常简单的事情,但我不知道为什么它不能编译。

这是脚本:

//@version=4
study("CrossOver", overlay = true)
sma_1 = sma (close, 4)
sma_2 = sma (close, 9)
sma_3 = sma (close, 18)

plot(sma_1, color = color.white)
plot(sma_2, color = color.red)
plot(sma_3, color = color.green)

longs = (sma_1 > sma_2) and (sma_2 > sma_3)
shorts = (sma_1 < sma_2) and (sma_2 < sma_3)
bgcolor(longs ? color.green : na)
bgcolor(shorts ? color.red : na)

这是我编译时的错误:

line 10: Undeclared identifier `color.white`;
line 11: Undeclared identifier `color.red`;
line 12: Undeclared identifier `color.green`

你的脚本在这里编译得很好: