PureBytes Links
Trading Reference Links
|
Hi traders,
I am trying to modify Jose's Centred MA that extends the last MA
value to the last trading date.
I hope to replace the extended part of the MA using an estimated
curve or a straight line with last few MA values.
As shown below, I calucalate the difference of the last 2 MA values
(maybe a +ve or -ve difference) and then add the difference to the
last MA values recursively.
But i failed to show the desired result after a number of trials.
Could you kindly advise on the algorithm. Thanks in advance for the
help.
Chu
==========================================
{ Centered MA - v2.0 }
{ Uses forward-referencing to center Mov Avg.}
{ Copyright 2005 Jose Silva
For personal use only.
http://www.metastocktools.com }
{ User inputs }
pds:=Input("MA periods",1,2600,10);
type:=Input("[1]EMA [2]SMA [3]TmSr [4]Tri [5]Var [6]Vol [7]
Wght",1,7,2);
{ Choose MA type:
1 - Exponential MA
2 - Simple MA
3 - Time Series MA
4 - Triangular MA
5 - Variable MA
6 - Volume adjusted MA
7 - Weighted MA }
ma:=
If(type=1,Mov(C,pds,E),
If(type=2,Mov(C,pds,S),
If(type=3,Mov(C,pds,T),
If(type=4,Mov(C,pds,TRI),
If(type=5,Mov(C,pds,VAR),
If(type=6,Mov(C,pds,VOL),
Mov(C,pds,W)))))));
{ Forward-reference MA }
center:=LastValue(Int(pds/2));
fwd:=Ref(ma,center);
{ Extend plot into null zone }
xtend:=LastValue(fwd+PREV-PREV);
{******* the line i add **********}
{extending using a straight line}
xtend:=If(xtend=Ref(xtend,-1),Ref(xtend,-1)*2-Ref(xtend,-2),xtend);
{ Restrict invalid initial MA plot }
ma:=Ref(Ref(xtend,pds-1),-pds+1);
{ Plot MA on price chart }
ma
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/
|