你能帮我解决这个错误吗。我是新手,正在将Tradingview pine脚本版本3转换为4,并得到以下错误:
脚本:
findprevious() => // finds previous three points (b, c, d, e)
ehl = iff(hl == 1, -1, 1)
loc1 = 0.0
loc2 = 0.0
loc3 = 0.0
loc4 = 0.0
xx = 0
for x = 1 to 1000 by 1
if hl[x] == ehl and not na(zz[x])
loc1 := zz[x]
xx := x + 1
break
ehl := hl
for x = xx to 1000 by 1
if hl[x] == ehl and not na(zz[x])
loc2 := zz[x]
xx := x + 1
break
ehl := iff(hl == 1, -1, 1)
for x = xx to 1000 by 1
if hl[x] == ehl and not na(zz[x])
loc3 := zz[x]
xx := x + 1
break
ehl := hl
for x = xx to 1000 by 1
if hl[x] == ehl and not na(zz[x])
loc4 := zz[x]
break
[loc1, loc2, loc3, loc4]
a = float(na)
b = float(na)
c = float(na)
d = float(na)
e = float(na)
if not na(hl)
[loc1, loc2, loc3, loc4] = findprevious() (Error line 66)
a := zz
b := loc1
c := loc2
d := loc3
e := loc4
e
错误:
第66行:应在每次计算中调用函数"#f0"以确保一致性。建议从此作用域提取调用。第66行:为了保持一致性,应在每次计算中调用函数"findprevior"。建议从此作用域提取调用。添加到图表enter code here
的脚本研究
如果有意义的话,它希望在主作用域中运行对连续数据进行操作的函数。例如,你会在尝试类似的东西时遇到类似的错误:
if x
bullCross := crossover(close, bullLine)
解决方案是在主作用域上调用函数,使它们执行每个条,然后确定如何处理输出。
所以可能是这样的:
a = float(na)
b = float(na)
c = float(na)
d = float(na)
e = float(na)
[loc1, loc2, loc3, loc4] = findprevious()
if not na(hl)
b := loc1
c := loc2
d := loc3
e := loc4
我忽略了zz
和e
,我不知道悬挂的e
在做什么。