我正在尝试使用 for 循环计算黄金交叉,但代码不起作用(实际上,即使我真的不知道它是否正确编写)。有 2 个金十字,但上面写着 0。我求你帮助我,我是编码新手,我会失去理智。
indicator("Cross count", overlay = true)
v1 = input.int(8, "Short WMA", minval=1)
v2 = input.int(21, "Long WMA", minval=1)
v3 = input.int(500, "Look Back Input", minval=10, step=10)
cp = 0
var label lbl = label.new(na, na, " ", style = label.style_label_left)
wmaS= ta.wma(close, v1)
wmaL = ta.wma(close, v2)
for i = 0 to v3
if ta.crossover(wmaS,wmaL)
cp := cp + 1
cp
plot(wmaS, color=color.purple)
plot(wmaL, color=color.orange)
label.set_xy(lbl, bar_index, high)
label.set_text(lbl, str.tostring(cp, "Golden Cross = "))`