General Topics
Markets
Technical Topics
Brokerage Firms
Community Lounge
Site Support

# Low Pass vs SMA

Discussion in 'Strategy Development' started by luckyputanski, Sep 16, 2012.

1. ### luckyputanski

I'm trying to compare effectiveness of simple moving average with low pass filter suggested by jcl.
Code for his low pass filter:

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] = (a-0.25*a2)*Data[0]
+ 0.5*a2*Data[1]
- (a-0.75*a2)*Data[2]
+ 2*(1.-a)*LP[1]
- (1.-a)*(1.-a)*LP[2];
}

First, I'd like to make sure that my spreadsheet calculates things properly.
First three closing prices are:
17.76, 17.83, 17.86.
In order to calculate low pass filter for last bar, I need low pass value for previous bar and a bar before. So first two LP values are simply security prices, then third value is calculated as in picture.
Did I make a mistake somewhere?

File size:
13.7 KB
Views:
458
2. ### panzerman

Look up work of John Ehlers if you are interested on low pass and band pass filters. Now, a filter is just an indicator and not a complete trading system or methodoligy, and an SMA is a lowpass filter.

Also, it doesn't really matter what parameters you choose. When you back test, you will find performance of all the moving average indicators about the same (i.e. not too impressive.)

3. ### luckyputanski

Whether SMA or LP is a trading system or not, is another story. JCL claims that low pass is much more effective than SMA and that's what I'm trying to establish in this thread.

4. ### stevegee58

Actually SMA and EMA are both low pass filters too. The low pass filter jcl posted is a 2 pole filter.

5. ### luckyputanski

Yes, SMA is a low pass filter too. That's I'm looking to replace SMA with filter posted by jcl, but so far I can't see any advantage.

6. ### stevegee58

The advantage is less lag. You only see it when you put a regular MA and the LPF on the chart with price.

7. ### luckyputanski

Ok, we getting somewhere with this thread, but it's painfully slow. I asked in the first post if I calculate LP correctly. Formula from the spreadsheet can be seen in the picture.

8. ### stevegee58

Here's a plot for price, EMA, SMA and LPF. Apologies for the resolution, sizing etc.

They all are 20 periods. Note how LPF follows the closest, followed by EMA and SMA.

I can't help with Excel stuff sorry.

File size:
45.6 KB
Views:
807
9. ### jcl

Luckyputanski: I'm also not using Excel often, so there may be problems that I don't see. For checking if your lowpass filter was correctly implemented, compare your chart with this one.

The price is S&P500 from June 2010. The green line is Lowpass, the red one SMA. In this chart both time periods are set up so that both have about the same lag, i.e. the peaks are at the same position: LowPass(500) and SMA(100). You can see that the SMA would give you more signals. You should get the same curves with your spreadsheet when it calculates correctly.

Code:
```function run()
{
set(PLOTPRICE+PLOTNOW);
var *Price = series(price());
plot("Lowpass",LowPass(Price,500),0,GREEN);
plot("SMA",SMA(Price,100),0,RED);

StartDate = 20100601;
NumDays = 100;
PlotWidth = 800;
}
```
Which indicator is better depends on your strategy. Usually less lag is better. But I've also seen strategies where the signals are delayed by a couple bars. In such a strategy the lowpass signal would give you no advantage.

10. ### Daring

The power of an average does not come from its speed but how price is acting towards it in the various main timeframes.

#10     Sep 16, 2012
ET IS FREE BECAUSE OF THE FINANCIAL SUPPORT FROM THESE COMPANIES: