我想写一个脚本,画一个移动平均线。
我希望颜色是动态的(上升时绿色,下降时红色)。
我试图使用iff函数,但是我得到了一个错误:Error: Could not find function or function reference 'iff'
//@version=5
indicator("SMA", overlay=true)
smaValue = ta.sma(close, 20)
// Error: Could not find function or function reference 'iff'.
smaColor = iff(smaValue[0] >= smaValue[1], color.green, color.red)
plot(smaValue, color=smaColor, title="SMA")
发布于 2022-07-17 14:18:15
您可以在Pine @version 5中使用三元:
smaColor = smaValue[0] >= smaValue[1] ? color.green : color.red
https://stackoverflow.com/questions/73012526
复制相似问题