Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/multithreading/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Pine script Pinescript-应在每次计算时调用函数_Pine Script - Fatal编程技术网

Pine script Pinescript-应在每次计算时调用函数

Pine script Pinescript-应在每次计算时调用函数,pine-script,Pine Script,我犯了这个错误 第5行:应在每次计算中调用函数“sma”,以确保一致性。建议从三元运算符或范围中提取调用 我正试图找出原因,但无法解决它。这是tradingview上的一个内置指示器,我想对其进行调整,但我还没来得及开始就被卡住了。脚本工作,但我希望它没有咨询 //@version=4 study(title="Williams Alligator", shorttitle="Alligator", overlay=true, resolution=&qu

我犯了这个错误 第5行:应在每次计算中调用函数“sma”,以确保一致性。建议从三元运算符或范围中提取调用

我正试图找出原因,但无法解决它。这是tradingview上的一个内置指示器,我想对其进行调整,但我还没来得及开始就被卡住了。脚本工作,但我希望它没有咨询

//@version=4
study(title="Williams Alligator", shorttitle="Alligator", overlay=true, resolution="")
smma(src, length) =>
    smma =  0.0
    smma := na(smma[1]) ? sma(src, length) : (smma[1] * (length - 1) + src) / length
    smma
jawLength = input(13, minval=1, title="Jaw Length")
teethLength = input(8, minval=1, title="Teeth Length")
lipsLength = input(5, minval=1, title="Lips Length")
jawOffset = input(8, title="Jaw Offset")
teethOffset = input(5, title="Teeth Offset")
lipsOffset = input(3, title="Lips Offset")
jaw = smma(hl2, jawLength)
teeth = smma(hl2, teethLength)
lips = smma(hl2, lipsLength)
plot(jaw, "Jaw", offset = jawOffset, color=#3BB3E4)
plot(teeth, "Teeth", offset = teethOffset, color=#FF006E)
plot(lips, "Lips", offset = lipsOffset, color=#36C711)
我已经弄明白了 我在条件行之前插入了一行并声明了smma值“sma(src,length)”而不是“0” 得到完全相同的结果,没有错误

smma(src, length) =>
    smma = sma(src, length) 
    smma := na(smma[1]) ? smma : (smma[1] * (length - 1) + src) / length
    smma