我一直在尝试在Trading View上编写高斯趋势线。尝试保存时不断出现以下错误:
“保存操作失败,原因:错误”。
我希望覆盖的趋势线是3、7、30、50、100、128和200。
请有人可以查看我的代码并让我知道我丢失了什么吗?
//@version=0.1
study(title="Gaussian MAs", overlay=true)
p1 = input(3, minval=1, maxval=999, title="3 Gaussian MA")
p2 = input(7, minval=1, maxval=999, title="7 Gaussian MA")
p3 = input(30, minval=1, maxval=999, title="30 Gaussian MA")
p4 = input(50, minval=1, maxval=999, title="50 Gaussian MA")
p5 = input(100, minval=1, maxval=999, title="100 Gaussian MA")
p6 = input(128, minval=1, maxval=999, title="128 Gaussian MA")
p7 = input(200, minval=1, maxval=999, title="200 Gaussian MA")
price = input(close)
pi=3.1415926535
w1=2*pi/p1
beta1 = (1 - cos(w1))/(pow(1.414,2.0/3) - 1)
alpha1 = -beta1 + sqrt(beta1*beta1 + 2*beta1)
ret1= pow(alpha1,4)*price+4*(1-alpha1)*nz(ret1[1])-6*pow(1-alpha1,2)*nz(ret1[2])+4*pow(1-alpha1,3)*nz(ret1[3])-pow(1-alpha1,4)*nz(ret1[4])
w2=2*pi/p2
beta2 = (1 - cos(w2))/(pow(1.414,2.0/3) - 1)
alpha2 = -beta2 + sqrt(beta2*beta2 + 2*beta2)
ret2= pow(alpha2,4)*price+4*(1-alpha2)*nz(ret2[1])-6*pow(1-alpha2,2)*nz(ret2[2])+4*pow(1-alpha2,3)*nz(ret2[3])-pow(1-alpha2,4)*nz(ret2[4])
w3=2*pi/p3
beta3 = (1 - cos(w3))/(pow(1.414,2.0/3) - 1)
alpha3 = -beta3 + sqrt(beta3*beta3 + 2*beta3)
ret3= pow(alpha3,4)*price+4*(1-alpha3)*nz(ret3[1])-6*pow(1-alpha3,2)*nz(ret3[2])+4*pow(1-alpha3,3)*nz(ret3[3])-pow(1-alpha3,4)*nz(ret3[4])
w4=2*pi/p4
beta4 = (1 - cos(w4))/(pow(1.414,2.0/3) - 1)
alpha4 = -beta4 + sqrt(beta4*beta4 + 2*beta4)
ret4= pow(alpha4,4)*price+4*(1-alpha4)*nz(ret4[1])-6*pow(1-alpha4,2)*nz(ret4[2])+4*pow(1-alpha4,3)*nz(ret4[3])-pow(1-alpha4,4)*nz(ret4[4])
w5=2*pi/p5
beta5 = (1 - cos(w5))/(pow(1.414,2.0/3) - 1)
alpha5 = -beta5 + sqrt(beta5*beta5 + 2*beta5)
ret5= pow(alpha5,4)*price+4*(1-alpha5)*nz(ret5[1])-6*pow(1-alpha5,2)*nz(ret5[2])+4*pow(1-alpha5,3)*nz(ret5[3])-pow(1-alpha5,4)*nz(ret5[4])
w6=2*pi/p6
beta6 = (1 - cos(w6))/(pow(1.414,2.0/3) - 1)
alpha6 = -beta6 + sqrt(beta6*beta6 + 2*beta6)
ret6= pow(alpha6,4)*price+4*(1-alpha6)*nz(ret6[1])-6*pow(1-alpha6,2)*nz(ret6[2])+4*pow(1-alpha6,3)*nz(ret6[3])-pow(1-alpha6,4)*nz(ret6[4])
w7=2*pi/p7
beta7 = (1 - cos(w7))/(pow(1.414,2.0/3) - 1)
alpha7 = -beta7 + sqrt(beta7*beta7 + 2*beta7)
ret7= pow(alpha7,4)*price+4*(1-alpha7)*nz(ret7[1])-6*pow(1-alpha7,2)*nz(ret7[2])+4*pow(1-alpha7,3)*nz(ret7[3])-pow(1-alpha7,4)*nz(ret7[4])
plot(ret1, style=line, linewidth=1, color=red, title="G1")
plot(ret2, style=line, linewidth=1, color=purple, title="G2")
plot(ret3, style=line, linewidth=1, color=orange, title="G3")
plot(ret4, style=line, linewidth=1, color=blue, title="G4")
plot(ret5, style=line, linewidth=1, color=black, title="G5")
plot(ret6, style=line, linewidth=1, color=green, title="G6")
plot(ret7, style=line, linewidth=1, color=yellow, title="G7")
答案 0 :(得分:1)
好吧,在松树脚本中没有version=0.1
。似乎您想要的是//@version=2
。