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];
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];
}
I'm assuming I have a syntax problem somewhere but I have not found out where. Does anyone have any ideas?
Thanks