[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[EquisMetaStock Group] Gaussian IIR Filter



PureBytes Links

Trading Reference Links

Hello I ran across this Tradestation webpage

https://www.tradestation.com/Discussions/Topic.aspx?
Topic_ID=31076&PAGE=1

where it discusses a 4 pole Gaussian IIR Filter developed by Ehler 
that can help smooth data with less lag.   

Several questions:

Is there an indicator like this for Metastock already that's widely 
available? If so where can I find it?

The JMA seems to be the best responsive adaptive moving average I'm 
aware of that's available and for awhile it seemed that the T3 was 
the best free one out there as suggested here

http://www.jurikres.com/faq/faq_ama.htm#betterthan 

but that looks dated.

I've seen a growing number of other filtered MAs like one based on 
Laguerre and recently the Hull AMA and then this Gaussian IIR. 
What's the current state of things in this development niche?  Is 
there a good article somewhere that's easily accessible that 
discusses all the new alternatives?

In any event I couldn't find one that's Metastock based so I decided 
to try my hand at converting the following EasyLanguage formula that 
was given in the above Tradestation link.


EasyLanguage formula:

{Gaussian Filter}
{Ported to EasyLanguage by: atavachron}
{Original author: DrKoch}
Inputs: Price(NumericSeries), Period(NumericSimple), poles
(NumericSimple);

variables: aa(0), b(0), w(0), x(0), y(0), y1(0), y2(0), y3(0), y4(0),
a_1(0), a_12(0), a_13(0), a_14(0), a2(0), a3(0), a4(0), Pi
(3.141592654),
sqrtOf2(1.414213562);

{If number of poles is < 0 or > 4 then return 0.}
{Number of filter poles must be between 1 and 4, inclusive}
If (poles >= 1) and (poles <= 4) then
begin
{initialization - performed only for first bar}
if CurrentBar = 1 then
begin
w = 2 * Pi / Period; {omega}
w = 180 * w / Pi; {in degrees}

b = (1 - cosine(w)) / (power(sqrtOf2, 2.0/poles) - 1.0);

aa = -b + squareroot(b*b + 2*b);
a_1 = 1.0 - aa;
a_12 = a_1 * a_1;
a_13 = a_1 * a_1 * a_1;
a_14 = a_12 * a_12;
a2 = aa * aa;
a3 = aa * aa * aa;
a4 = a2 * a2;

y1 = Price;
y2 = y1;
y3 = y2;
y4 = y3;
end;

{Calculate your indicator value here}
x = Price;

if (poles = 1) then
y = aa * x + a_1 * y1
else if (poles = 2) then
y = a2 * x + 2 * a_1 * y1 - a_12 * y2
else if (poles = 3) then
y = a3 * x + 3 * a_1 * y1 - 3 * a_12 * y2 + a_13 * y3
else if (poles = 4) then
y = a4 * x + 4 * a_1 * y1 - 6 * a_12 * y2 + 4 * a_13 * y3 - a_14 * 
y4;

y4 = y3; {delayed by four bars}
y3 = y2; {delayed by three bars}
y2 = y1; {delayed by two bars}
y1 = y; {delayed by one bar}

Gauss = y;
end
else
Gauss = 0.0;

____________________________________________________________


Here's my attempt at converting the above:

____________________________________________________________

Period:=Input("Period", 0, 50, 10);
Poles:=Input("Poles", 1, 4, 1);
x:=P;

wv:=2 * 3.141592654 / Period;
ww:=180 * wv / 3.141592654;

b:= (1 - Cos(ww)) / (Power(1.414213562, 2.0/poles) - 1.0);

aa:= -b + Sqrt(b*b + 2*b);
a1:= 1.0 - aa;
a12:= a1 * a1;
a13:= a1 * a1 * a1;
a14:= a12 * a12;
a2:= aa * aa;
a3:= aa * aa * aa;
a4:= a2 * a2;

y1:= aa * x + a1 * If(Cum(1)<5, P, PREV);
y2:= a2 * x + 2 * a1 * y1 - a12 * If(Cum(1)<5, P, PREV);
y3:=a3 * x + 3 * a1 * y1 - 3 * a12 * y2 + a13 * If(Cum(1)<5, P, 
PREV); 
y4:= a4 * x + 4 * a1 * y1 - 6 * a12 * y2 + 4 * a13 * y3 - a14 * If
(Cum(1)<5, P, PREV);

y:=
If(poles=1, aa * x + a1 * y1,
If(poles=2, a2 * x + 2 * a1 * y1 - a12 * y2,
If(poles=3, a3 * x + 3 * a1 * y1 - 3 * a12 * y2 + a13 * y3,
If(poles=4, a4 * x + 4 * a1 * y1 - 6 * a12 * y2 + 4 * a13 * y3 - a14 
* y4, 0)
)
)
);

y

_______________________________________________________

I think I'm doing something wrong since I read that if it is run as 
a 1 pole indicator it should be the same as a regular EMA, but 
that's not the result I'm getting. I am NOT a programmer and I am 
not versed in EasyLanguage so I was guessing most of the time.  For 
example I'm not sure why there seem to be 2 w expressions in the 
Easylanguage formula. Could someone look this over and suggest 
improvements? 









------------------------ Yahoo! Groups Sponsor --------------------~--> 
Try Online Currency Trading with GFT. Free 50K Demo. Trade 
24 Hours. Commission-Free. 
http://us.click.yahoo.com/RvFikB/9M2KAA/U1CZAA/BefplB/TM
--------------------------------------------------------------------~-> 

 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/equismetastock/

<*> To unsubscribe from this group, send an email to:
    equismetastock-unsubscribe@xxxxxxxxxxxxxxx

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/