我从tradingview.com的公共图书馆复制了以下代码。它似乎是用较旧版本的pine脚本编写的。我当前使用的是版本4,因此我感觉到错误是因为我从自身内部将函数smma称为递归函数,但不确定如何解决该错误。
cv2.waitKey(0)
答案 0 :(得分:1)
Baris Yakut是正确的。您应该在使用变量之前声明它。像这样:
//@version=4
study("My Strategy", overlay=true)
//SUITABLE FOR INTRADAY IN BANK NIFTY 5MIN 10MIN AND 15MIN APPLICAPABLE IN ANY TIME FRAME
//TEST YOUR STRATEGY
//borrowed this concept from someone else and modified it for our needs
//teach me pine i wanna learn from you =>skgs01@gmail.com
smma(src, length) =>
var float smma = na
smma := na(smma[1]) ? sma(src, length) : (smma[1] * (length - 1) + src) / length
smma
jawLength = input(13, "Jaw Length")
jawOffset = input(8, "Jaw Offset")
jaw = smma(hl2, jawLength)
plot(jaw, "Jaw", color=color.blue, offset=jawOffset)