为什么我总是在pine脚本上收到“未声明的标识符”错误消息?

2024-09-27 04:27:13 发布

您现在位置:Python中文网/ 问答频道 /正文

我一直在pine脚本上收到未声明标识符的错误消息,现在它变得令人沮丧

line 19 : Undeclared identifier 'lag_s_k';
line 19 : Undeclared identifier 's1';
line 19 : Undeclared identifier  's3';
line 22 : Undeclared identifier 'vol';
line 24 : Undeclared identifier 'vol';
line 26 : Undeclared identifier 'vol_m'

这是完整的代码,谢谢大家

dummydv = input(false, title="Damiani Volatmeter")
usevolmode = true 
//input(true, title = "use 
volume Mode")
vis_atr = input(13)
vis_std = input(20)
sed_atr = input(40)
sed_std = input(100)
threshold_level = input(1.4)
lag_supressor = input(true)
atrv(len)=>rma(volume,len)
//DV(13,20,40,100,1.4,true) 
  DV(vis_atr,vis_std,sed_atr,sed_std, threshold_level,lag_supressor)=>
 vol = 0.0
 lag_s_K = 0.5
 s1=nz(vol[1], 0)
 s3=nz(vol[3], 0)

vol = lag_supressor ? atr(vis_atr) / atr(sed_atr) + lag_s_K*(s1-s3) : atr(vis_atr) / atr(sed_atr)
anti_thres = stdev(close, vis_std) / stdev(close, sed_std)
t = threshold_level - anti_thres
vol_m = vol > t ? -1 : 0.03

plot (title="V",  series=vol, color=color.lime)
plot(title="A", series=t, color=color.silver)
plot(title="T", series=vol_m, color=color.maroon)

Tags: trueinputs3titlelinevissedlag
1条回答
网友
1楼 · 发布于 2024-09-27 04:27:13

在函数内声明的变量只能在该函数内使用。注意正确的空格数也很重要

dummydv = input(false, title="Damiani Volatmeter")
usevolmode = true 
//input(true, title = "use volume Mode")
vis_atr = input(13)
vis_std = input(20)
sed_atr = input(40)
sed_std = input(100)
threshold_level = input(1.4)
lag_supressor = input(true)
atrv(len)=>rma(volume,len)
//DV(13,20,40,100,1.4,true) 
//DV(vis_atr,vis_std,sed_atr,sed_std, threshold_level,lag_supressor)=>
vol = 0.0
lag_s_K = 0.5
s1=nz(vol[1], 0)
s3=nz(vol[3], 0)

vol := lag_supressor ? atr(vis_atr) / atr(sed_atr) + lag_s_K*(s1-s3) : atr(vis_atr) / atr(sed_atr)
anti_thres = stdev(close, vis_std) / stdev(close, sed_std)
t = threshold_level - anti_thres
vol_m = vol > t ? -1 : 0.03

plot (title="V",  series=vol, color=color.lime)
plot(title="A", series=t, color=color.silver)
plot(title="T", series=vol_m, color=color.maroon)

相关问题 更多 >

    热门问题