我在编写指标代码时不断收到错误消息。我希望它在四个条件成立时打印一个三角形。
Condition 1 = 20ema crossunder 100ema 3 bars ago
Condition 2 = 20ema at 3 bars ago minus 20ema at current bar >= 29.4
Condition 3 = 100ema at 3 bars ago minus 100ema at current bar >=13.64
Condition 4 = 20ema at 33 bars ago minus 20ema at 3 bars ago >= 29.3`
这是我的脚本:
//@version=5
indicator("My Script")
EMA20_= ta.ema(close,20)
EMA100_= ta.ema(close,100)
bool isCond1 = (ta.crossunder(EMA20_, EMA100_)[3] and sum(EMA20_[3] - EMA20_[0])>= 29.4 and sum(EMA100_[3] - EMA100_[0])>= 13.6 and sum(EMA20_[33] - EMA20_[3])>= 29.3)
plot(ta.ema(close,20),color=color.red)
plot(ta.ema(close,100),color=color.blue)
plotshape(series = isCond1 , signal, "signal", "▲", location.top, size = size.tiny, offset = - 2)
要在四个条件成立时打印三角形,请尝试以下操作:
plotshape(isCond1, "signal", shape.triangleup, location.top, size = size.tiny, offset = - 2)