Laguerre Filter on price

Category: Indicators By: dave Created: March 24, 2016, 3:47 PM
March 24, 2016, 3:47 PM
Indicators
3 Comments

The Laguerre filter is a mathematical filter used to have a better idea of price direction while denoising it. It were made by John Ehlers. Everything can be denoised by applying this filter, from oscillator like RSI to any others trend indicators. This one is only for price purpose, so I think that someone can adapt it for other things of interest of the community.

//parameters :
//length = 20
//Elements = 5

Price = (High+Low+Open+Close)/4

Diff = ABS(Price - 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*Price + (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 = Price
ENDIF

RETURN Filt AS "Laguerre1"

 

Download
Filename: Laguerre-Filter.itf
Downloads: 372
dave Junior
This author is like an anonymous function, present but not directly identifiable. More details on this code architect as soon as they exit 'incognito' mode.
Author’s Profile

Comments

Logo Logo
Loading...