Rank: Advanced Member
Groups: Registered, Registered Users, Subscribers, Unverified Users Joined: 10/28/2004(UTC) Posts: 3,111 Location: Perth, Western Australia
Was thanked: 16 time(s) in 16 post(s)
|
Steve, The Gaussian MA is simply an EMA of an EMA. Used mainly in digital signal processing, the concept of n-pole filters can be brought into play here. A four-pole filter applied to the close price can be surmised as: Code:prd:=21;
data:=CLOSE;
gema:=Mov(Mov(Mov(Mov(data,prd,E),prd,E),prd,E),prd,E);
{plot}
gema;
For some people who require a high degree of data smoothing, but consider the lag in this filter is too much use something more like: Code:prd:=21;
data:=CLOSE;
gema:=Mov(Mov(Mov(Mov(data,prd,E),2,E),2,E),2,E);
{plot}
gema;
and many other variations of the concept too!
-- On another note: although your algorithm for the EMA is correct, to write this for MS: Code:prd:=21;
data:=CLOSE;
m:=2/(prd+1);
ema:=((data-PREV)*m)+PREV;
{plot}
ema;
requires two recursive PREV functions which are notoriously slow, but the same results can be achieved using: Code:prd:=21;
data:=CLOSE;
m:=2/(prd+1);
ema:=If(Cum(IsDefined(data))=1,data,(m*data)+((1-m)*PREV));
{plot}
ema;
which has only one recursive function. Also note how the function is seeded on the first bar the data is valid to avoid any NA after the data bars have been defined. The first function (gema) will have a large gap of NA bars at the very left hand side of the chart, the only way to overcome this is with an external function. (It might not be the only but it is certainly the best and fastest!) Hope this helps. wabbit [:D]
|