//parameters :
length = 20
Elements = 5
mPrice = (High+Low+Open+Close)/4
Diff = ABS(mPrice - Filt[1])
HH = Diff
LL = Diff
FOR count = 0 TO Length - 1
IF Diff[count] > HH THEN
HH = Diff[count]
ENDIF
IF Diff[count] < LL THEN
LL = Diff[count]
ENDIF
NEXT
If Barindex > Length AND HH - LL <> 0 THEN
Calcul = (Diff - LL) / (HH - LL)
// Calculate MEDIAN with 5 Elements. Vary at will
Data = Calcul
NrElements = Elements
FOR X = 0 TO NrElements-1
M = Data[X]
SmallPart = 0
LargePart = 0
FOR Y = 0 TO NrElements-1
IF Data[Y] < M THEN
SmallPart = SmallPart + 1
ELSIF Data[Y] > M THEN
LargePart = LargePart + 1
ENDIF
IF LargePart = SmallPart AND Y = NrElements-1 THEN
Median = M
BREAK
ENDIF
NEXT
NEXT
alpha = Median
L0 = alpha*mPrice + (1 - alpha)*L0[1]
L1 = -(1 - alpha)*L0 + L0[1] + (1 - alpha)*L1[1]
L2 = -(1 - alpha)*L1 + L1[1] + (1 - alpha)*L2[1]
L3 = -(1 - alpha)*L2 + L2[1] + (1 - alpha)*L3[1]
FILT = (L0 + 2*L1 + 2*L2 + L3) / 6
ENDIF
IF Barindex < 1 THEN
FILT = mPrice
ENDIF
RETURN Filt AS "Laguerre1"