I have a pinescript v2 that needs to be converted to v4 or v5, but I still haven't understood how, any inputs will be useful, thanks. This script was developed a long time back and visiting it now is confusing me. I have been reading that the variables need to be declared first, I get that, but what is the most efficient way to convert this into v4 or v5 of pine?
strategy("Slow Heiken Ashi",overlay=false,precision=0)
//by Glaz.
//KAMA function
p=input(6,title='Period')
fastend=input(0.666,step=0.001)
slowend=input(0.0645,step=0.0001)
kama(close,amaLength)=>
diff=abs(close[0]-close[1])
signal=abs(close-close[amaLength])
noise=sum(diff, amaLength)
efratio=noise!=0 ? signal/noise : 1
smooth=pow(efratio*(fastend-slowend)+slowend,2)
kama=nz(kama[1], close)+smooth*(close-nz(kama[1], close))
kama
//Slow Heiken Ashi
hakamaper=1
Signal=input(true)
Om=sma(open,p)
Hm=sma(high,p)
Lm=sma(low,p)
Cm=sma(close,p)
vClose=(Om+Hm+Lm+Cm)/4
vOpen= kama(vClose[1],hakamaper)
vHigh= max(Hm,max(vClose, vOpen))
vLow= min(Lm,min(vClose, vOpen))
// Plots
vcolor= vOpen>vClose ?red:green
plotcandle(vOpen,vHigh,vLow,vClose,color=vcolor)
//signals
plotchar(Signal?(cross(vOpen,vClose) and vOpen[1]<vClose[1]?vHigh:na):na,char='▼',color=white,transp=0,location=location.absolute)
plotchar(Signal?(cross(vOpen,vClose) and vOpen[1]>vClose[1]?vLow:na):na,char='▲',color=white,transp=0,location=location.absolute)
