.

## Problem with Ehlers High Pass Filter

Moderators: mntiwana, mrtools

### Problem with Ehlers High Pass Filter

#1
Hello,

I am trying to make an indicator with Ehlers formula for a high pass filter with a user input cut off period. The formula Ehlers writes in is paper "Predictive Indicators for Effective Trading Strategies" is coded in EasyLanguage as follows:

Code: Select all

``````//Highpass filter cyclic components whose periods are shorter than 48 bars
alpha1 = (Cosine(.707*360 / 48) + Sine (.707*360 / 48) -1) / Cosine(.707*360 / 48);
HP  =  (1 -alpha1    /  2)*(1 -alpha1  /  2)*(Close -2*Close[1]  +  Close[2])  +  2*(1 -alpha1)*HP[1] -(1 -alpha1)*(1 -alpha1)*HP[2];``````
I wrote in mql4 the follwing:

Code: Select all

`````` for (i=limit; i>=0; i--){
Price[i] = (High[i]+Low[i])/2;
alpha = MathCos(0.707*360/CutOff) + MathSin((0.707*360/CutOff)-1) / MathCos(0.707*360/CutOff);
highPass[i] = (1-alpha/2) * (1-alpha/2) * (Price[i] - 2*Price[i+1] + Price[i+2]) + 2 * (1-alpha) * highPass[i+1] - (1-alpha) * (1-alpha) * highPass[i+2];
}
``````
Everything compiles fine with no errors or warnings but when attached to a chart the Data Window returns a value of "-nan(ind)" for the highPass buffer.
I'm assuming I have a syntax problem somewhere but I have not found out where. Does anyone have any ideas?
Thanks

1. ### Similar Topics

1. #### Nadex Bans Husband and Wife Over Money Pass Scheme

0 Replies 727 Views

by TheNews, Sat Apr 08, 2017 5:21 pm in Broker Talk

0 Replies
727 Views
Last post by TheNews
Sat Apr 08, 2017 5:21 pm
2. #### Ehlers Indicators

132 Replies 23132 Views

by mntiwana, Wed Aug 23, 2017 6:07 am in MT4 Indicators

132 Replies
23132 Views
Last post by global
Fri Jan 04, 2019 1:48 pm