The Laguerre filter is really cool. But the evaluation of Gamma is not always obvious. I propose here a filter of my own, named for the occasion “Carnazzi filter”, which is none other than a Laguerre filter preceded by an estimation function of the Gamma parameterized by a period length. The estimation function is designed to be strongly correlated with what would be given by an ALMA.
Intuitively, I think that the calculation of the Delta correction factor can be computed more formally but this requires signal processing knowledge that I don’t have 🙂
Your comments/modifications on the Delta refinement are welcome 😉
//Indicateur: Filtre de Carnazzi
//(c) 2021 Bruno Carnazzi
// Params
Length = 200
Series = CustomClose
once l0 = Series
once l1 = Series
once l2 = Series
once l3 = Series
IF BarIndex = 0 THEN
AFR = Series
if length <= 50 then
delta = 12
elsif length <= 200 then
delta = 16
else
delta = 16 * (200/length)
endif
corrlength = length + delta
gamma = 2 * (1 - 1/(0.1*corrlength)) - 1
if gamma < 0 then
gamma = 0
endif
ELSE
l0 = (1 - gamma) * Series + gamma * l0[1]
l1 = -gamma * l0 + l0[1] + gamma * l1[1]
l2 = -gamma * l1 + l1[1] + gamma * l2[1]
l3 = -gamma * l2 + l2[1] + gamma * l3[1]
AFR = (l0 + 2 * l1 + 2 * l2 + l3) / 6
ENDIF
return AFR