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

Re: [Metastockusers] Variable Moving Average initialization



PureBytes Links

Trading Reference Links

Gary

Seeding the appropriate bar is the key thing here.
If(Cum(1)<=(Smooth+2),C,

and then forcing the output to have the appropriate number of N/A bars is as
simple as forcing it to the known N/A period any function you care to use.
If(Sum(C,Smooth+2)>0,VIDYA,VIDYA);

  {VIDYA (9,20)}
Length:=Input("Length",1,200,9);
Smooth:=Input("Smoothing",1,200,20);
AbsCMO:=(Abs(CMO(C,Length)))/100;
SC:=2/(Smooth+1);
VIDYA:=If(Cum(1)<=(Smooth+2),C,(SC*AbsCMO*CLOSE)+(1-(SC*AbsCMO))*PREV);
If(Sum(C,Smooth+2)>0,VIDYA,VIDYA);

Some extra information. Notice how it is possible to seed an EMA on bar one
in the following EMA code. The fact that the plot doesn't start until bar
two is down to the PREV function.

  {Exponential Moving Average}
A:=Input("Periods",1,99,20);
B:=P; {target data array - usually CLOSE}
R:=2/(A+1);
If(Cum(1)=1,B,PREV*(1-R)+B*R);

Roy

----- Original Message ----- 
From: "Gary" <garyk176@xxxxxxx>
To: <Metastockusers@xxxxxxxxxxxxxxx>
Sent: Thursday, July 17, 2003 7:00 PM
Subject: [Metastockusers] Variable Moving Average initialization


> Can anyone shed light on how I could initialize a Variable Moving
> Average in the same way that Metastock's built-in VMA indicator is
> initialized?  This indicator is based on Chande's VIDYA, which uses
> Chande's CMO as a volatility index to control the rate of change of
> the variable moving average.  The built-in VMA is based on a 9-period
> CMO, and if the selected length of the moving average is 10, it
> appears that MetaStock waits 9 bars to calculate the starting CMO
> value, then begins calculating the moving average, so it's about 20
> bars before the first value of the MA is plotted.  And, that first
> value appears to be the close of the initial bar.
>
> When I attempt to duplicate this in the indicator builder, using
> formulas from the Guppytraders site as a starting point, my indicator
> starts at the 10th bar for a 10-period moving average, so I'm
> obviously starting the calculation of both the CMO-based volatility
> index and the MA itself, together on the first bar.  In addition,
> depending on how I use the IF() and Cum() functions to initialize it,
> the initial values of the VMA are either at or near zero, or using
> the close for the first several bars, which means it takes quite a
> while for the weight of those incorrect initial values to drop enough
> that my VMA stabilizes and matches the MetaStock version.
>
> Seems to me that it would be helpful if I had a MetaStock equivalent
> of the Excel =N/A function - the indicator simply wouldn't exist to
> be plotted until a specified bar, and the first calculated value
> would simply be based on the close of the previous bar.  Using the IF
> and CUM functions, the best I can do is have two alternative
> calculations for before and after the desired bar, rather than simply
> starting the calculation at the desired bar and having NO value for
> the indicator prior to that point.  Any suggestions, anyone?
>
> Thank you.
>
> Gary
>
>
>
>
> To unsubscribe from this group, send an email to:
> Metastockusers-unsubscribe@xxxxxxxxxxx
>
>
>
> Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
>
>
>
>



------------------------ Yahoo! Groups Sponsor ---------------------~-->
Free shipping on all inkjet cartridge & refill kit orders to US & Canada. Low prices up to 80% off. We have your brand: HP, Epson, Lexmark & more.
http://www.c1tracking.com/l.asp?cid=5510
http://us.click.yahoo.com/GHXcIA/n.WGAA/ySSFAA/zMEolB/TM
---------------------------------------------------------------------~->

To unsubscribe from this group, send an email to:
Metastockusers-unsubscribe@xxxxxxxxxxx

 

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