MetaStock™ Zone Forum & FAQ Artykuły Linki Elliott Waves EasyLanguage™ Zone

A B C D E F G H I J K L M N O P R S T U V W Y Z #

Cyclical MA Projection by Andrew Tomlinson
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

===========================================

This is one possible projection solution that we came up with a few weeks ago with help from Jose and Roy. Its hard wired for a 9-day average, but gives one idea of how to do it. Like any projection its less reliable the further out it goes.

Andrew


Cyclical MA Projection (9)

{with help from Jose & Roy}
P1:=9;
Pr:=(O+H+L+C)/4;
MA:=Mov(Pr,P1,TRI);
Shift:=Round(p1/2);
center:=LastValue(Shift);
CMA:=Ref(MA,center);
y:=LastValue(CMA+PREV-PREV);
CMA:=If(y>0,y,Pr);
CMA1:=Ref(Mov(Pr,P1-1,TRI),center-1);
y:=LastValue(CMA1+PREV-PREV);
CMA1:=If(y>0,y,Pr);
CMA2:=Ref(Mov(Pr,P1-2,TRI),center-2);
y:=LastValue(CMA2+PREV-PREV);
CMA2:=If(y>0,y,Pr);
CMA3:=Ref(Mov(Pr,P1-3,TRI),center-3);
y:=LastValue(CMA3+PREV-PREV);
CMA3:=If(y>0,y,Pr);
CMA4:=Ref(Mov(Pr,P1-4,TRI),center-4);
y:=LastValue(CMA4+PREV-PREV);
CMA4:=If(y>0,y,Pr);
CMA5:=Ref(Mov(Pr,P1-5,TRI),center-5);
y:=LastValue(CMA5+PREV-PREV);
CMA5:=If(y>0,y,Pr);

CMAP:=
If(Cum(1)=LastValue(Cum(1)-center+1),CMA1,
If(Cum(1)=LastValue(Cum(1)-center+2),CMA2,
If(Cum(1)=LastValue(Cum(1)-center+3),CMA3,
If(Cum(1)=LastValue(Cum(1)-center+4),CMA4,
If(Cum(1)=LastValue(Cum(1)-center+5),CMA5,CMA)))));

CMAP;

 

 

Andrew,

thanks a lot for your help.

Chu

Source / From: TOP
EquisMetastock[at]yahoogroups[dot]com

Equis and MetaStock® and MetaStock Professional® are registered trademarks of Equis International. Achelis Binary Wave®, The DownLoader®,
Expert Advisor®, OptionScope®, Quotecenter® and Smart Charts® are trademarks of Equis International, a Thomson Reuters company.

TradeStation® Pro, TradeStation® 2000i, OptionStation®, SuperCharts®, PowerEditor® and EasyLanguage®
are registered trademarks of TradeStation Technologies, Inc. Other names and marks referred to are the property of their respective owners.

All information provided on this website is for educational purposes only. Trading involves risk, including possible loss of principal and other losses.

Ten i inne materiały na tej stronie zostały zamieszczone zostały jedynie w celach edukacyjnych, nie ponoszę żadnej odpowiedzialno¶ci za ich stosowanie.

Gra na giełdzie i rynkach walutowych (FOREX) niesie ze sob± ryzyko poważnych strat finansowych!