Convert pine script old version to version 5
Posted: Tue Feb 01, 2022 4:07 am
Hello,
I recently start to learn Pine code few weeks ago (huge thanks to Mathew for the fantastic tutorial !!!).
I am trying to convert an old code I found from #madrid into version 5
ssFilter( price, lowerBand ) =>
angle = sqrt(2)*PI/lowerBand
a1= exp(-angle)
b1 = 2*a1*cos(angle)
c2 = b1
c3 = -a1*a1
c1 = 1 - c2 -c3
filt = c1*(price + nz(price[1]))/2 + c2*nz(filt[1]) + c3*nz(filt[2])
But I get the following error:
Add to Chart operation failed, reason: line 26: Undeclared identifier `filt`
so I have try the following thing:
ssFilter(close, lowerBand) =>
angle = sqrt(2)*PI/lowerBand
a1= exp(-angle)
b1 = 2*a1*cos(angle)
c2 = b1
c3 = -a1*a1
c1 = 1 - c2 -c3
c1*(close + nz(close[1]))/2 + c2*nz(filt[1]) + c3*nz(filt[2])
filt := ssFilter(close, lowerBand)
but I still have the same error:
line 25: Undeclared identifier `filt`
if anyone know how to fix it your help will be greatly appreciated!
I recently start to learn Pine code few weeks ago (huge thanks to Mathew for the fantastic tutorial !!!).
I am trying to convert an old code I found from #madrid into version 5
ssFilter( price, lowerBand ) =>
angle = sqrt(2)*PI/lowerBand
a1= exp(-angle)
b1 = 2*a1*cos(angle)
c2 = b1
c3 = -a1*a1
c1 = 1 - c2 -c3
filt = c1*(price + nz(price[1]))/2 + c2*nz(filt[1]) + c3*nz(filt[2])
But I get the following error:
Add to Chart operation failed, reason: line 26: Undeclared identifier `filt`
so I have try the following thing:
ssFilter(close, lowerBand) =>
angle = sqrt(2)*PI/lowerBand
a1= exp(-angle)
b1 = 2*a1*cos(angle)
c2 = b1
c3 = -a1*a1
c1 = 1 - c2 -c3
c1*(close + nz(close[1]))/2 + c2*nz(filt[1]) + c3*nz(filt[2])
filt := ssFilter(close, lowerBand)
but I still have the same error:
line 25: Undeclared identifier `filt`
if anyone know how to fix it your help will be greatly appreciated!