I’ve been getting undeclared identifier’ error message on pine script and now it’s getting frustrating.
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'
This is the full code, Thanks y’all.
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)
Advertisement
Answer
Variables that are declared inside a function can only be used inside that function. It is also important to observe the correct number of spaces.
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)