Quote:
Quote from jcl:
Highpass, lowpass, and bandpass filters. This is the liteC code for a simple second degree lowpass filter:
Code:
var smoothF(int period) { return 2./(period+1); }
var LowPass(var *Data, int Period)
{
var *LP = series(*Data,3);
var a = smoothF(Period);
var a2 = a*a;
return LP[0] = (aa2/4)*Data[0]
+ 0.5*a2*Data[1]
 (a0.75*a2)*Data[2]
+ 2*(1.a)*LP[1]
 (1.a)*(1.a)*LP[2];
}
This is no moving average. MA crossing strategies are normally not profitable because of lag.
Using such filters in trade strategies is described on a website to which I can't post a link here out of consideration for the sponsors of this forum. I already got chastised by a moderator for posting too much info.

This filter certainly has the characteristic frequency response of a low pass filter. Unfortunately the charting tools I use don't have the capability to evaluate it but I note it can be rewritten as:
EMA( EMA( (1/a0.25)*Data[0]+0.24*Data[1](1/a0.75)*Data[2] ))
where EMA is the standard EMA function.
Why not use the zero lag EMA which is first order and not as lagging as a standard EMA, although it isn't a low pass filter:
EMA( 2*Data[0]Data[k] ) with k=1 or k=2