I tried to convert pine v2 iff function to v5 but I kept getting this error:
line 32: Undeclared identifier 'vwapsum';
line 33: Undeclared identifier 'volumesum';
line 34: Undeclared identifier 'v2sum'
this one is original v2 script:
newSession = iff(change(start), 1, 0)
vwapsum = iff(newSession, hl2*volume, vwapsum[1]+hl2*volume)
volumesum = iff(newSession, volume, volumesum[1]+volume)
v2sum = iff(newSession, volume*hl2*hl2, v2sum[1]+volume*hl2*hl2)
myvwap = vwapsum/volumesum
dev = sqrt(max(v2sum/volumesum - myvwap*myvwap, 0))
and this is one v5 that I tried to create but give an error
newSession = ta.change(start) ? 1 : 0
vwapsum = newSession ? hl2*volume : vwapsum[1]+hl2*volume
volumesum = newSession ? volume : volumesum[1]+volume
v2sum = newSession ? volume*hl2*hl2 : v2sum[1]+volume*hl2*hl2
myvwap = vwapsum/volumesum
dev = math.sqrt(math.max(v2sum/volumesum - myvwap*myvwap, 0))