I’ve been getting undeclared identifier’ error message on pine script and now it’s getting frustrating.
JavaScript
x
7
1
line 19 : Undeclared identifier 'lag_s_k';
2
line 19 : Undeclared identifier 's1';
3
line 19 : Undeclared identifier 's3';
4
line 22 : Undeclared identifier 'vol';
5
line 24 : Undeclared identifier 'vol';
6
line 26 : Undeclared identifier 'vol_m'
7
This is the full code, Thanks y’all.
JavaScript
1
27
27
1
dummydv = input(false, title="Damiani Volatmeter")
2
usevolmode = true
3
//input(true, title = "use
4
volume Mode")
5
vis_atr = input(13)
6
vis_std = input(20)
7
sed_atr = input(40)
8
sed_std = input(100)
9
threshold_level = input(1.4)
10
lag_supressor = input(true)
11
atrv(len)=>rma(volume,len)
12
//DV(13,20,40,100,1.4,true)
13
DV(vis_atr,vis_std,sed_atr,sed_std, threshold_level,lag_supressor)=>
14
vol = 0.0
15
lag_s_K = 0.5
16
s1=nz(vol[1], 0)
17
s3=nz(vol[3], 0)
18
19
vol = lag_supressor ? atr(vis_atr) / atr(sed_atr) + lag_s_K*(s1-s3) : atr(vis_atr) / atr(sed_atr)
20
anti_thres = stdev(close, vis_std) / stdev(close, sed_std)
21
t = threshold_level - anti_thres
22
vol_m = vol > t ? -1 : 0.03
23
24
plot (title="V", series=vol, color=color.lime)
25
plot(title="A", series=t, color=color.silver)
26
plot(title="T", series=vol_m, color=color.maroon)
27
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.
JavaScript
1
26
26
1
dummydv = input(false, title="Damiani Volatmeter")
2
usevolmode = true
3
//input(true, title = "use volume Mode")
4
vis_atr = input(13)
5
vis_std = input(20)
6
sed_atr = input(40)
7
sed_std = input(100)
8
threshold_level = input(1.4)
9
lag_supressor = input(true)
10
atrv(len)=>rma(volume,len)
11
//DV(13,20,40,100,1.4,true)
12
//DV(vis_atr,vis_std,sed_atr,sed_std, threshold_level,lag_supressor)=>
13
vol = 0.0
14
lag_s_K = 0.5
15
s1=nz(vol[1], 0)
16
s3=nz(vol[3], 0)
17
18
vol := lag_supressor ? atr(vis_atr) / atr(sed_atr) + lag_s_K*(s1-s3) : atr(vis_atr) / atr(sed_atr)
19
anti_thres = stdev(close, vis_std) / stdev(close, sed_std)
20
t = threshold_level - anti_thres
21
vol_m = vol > t ? -1 : 0.03
22
23
plot (title="V", series=vol, color=color.lime)
24
plot(title="A", series=t, color=color.silver)
25
plot(title="T", series=vol_m, color=color.maroon)
26