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

[EquisMetaStock Group] Re: Variable length moving averages



PureBytes Links

Trading Reference Links


We use this often, but we code the moving average ourself.  If you
want to construct a moving average of length say n days, calculate the
weight as

    a = 2 / ( 1 + n )

and, using this weight, the moving average of say C as

    m = ( 1 - a ) * Ref(m,-1) + a * C

I've actually not used Metastock for this, and am not sure it will
work, but this is the idea.  Let me know the results!  You also need
a start up value, so use

    m = C

for the first value.  We often don't even bother with the length,
but work directly with the weight, and pick say a = 0.01 for a very
slow or a = 0.25 for a very fast moving average (translates into a
199 and 7 day if my math is not failing me).

Now, to vary the length, vary this 'a' parameter.  Say you have a
rule, and want to make the moving average slower or faster based on
the rule, then do something lie

    a = a * ( 1 + faster * 0.01 - slower * 0.01 )

If faster is true you will increase the weight by 1% and if slower is
true you will decrease it by 1%.

Regards
MG Ferreira
TsaTsa EOD Programmer and trading model builder
http://www.ferra4models.com
http://fun.ferra4models.com 

--- In equismetastock@xxxxxxxxxxxxxxx, meta_scott <no_reply@xxxx> wrote:
> 
> 
> Hello,
> 
> Does anyone know a clean way of calculating exponential moving 
> averages of variable length?  THe second parameter of tmov function 
> must be a constant.
> 
> Thanks,
> 
> Scott





------------------------ Yahoo! Groups Sponsor --------------------~--> 
Has someone you know been affected by illness or disease?
Network for Good is THE place to support health awareness efforts!
http://us.click.yahoo.com/Rcy2bD/UOnJAA/cosFAA/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/