log in     sign up for free
 
You can't make money if you're not willing to lose. It's like breathing in, but not being willing to breathe out. Various types of exits will help you do this (i.e., breathe fully), including trailing stops and the percent retracement stop.
Van K. Tharp
 
 
Home
systems (284)
 
Special offer: buy MetaStock (try for free)   |   Reuters QuoteCenter Real-Time Data (get a free month)   |   EOD Data
 

Buy

MetaStock

     (special offer)
 
 
 

Buy

EOD data for MetaStock

     (special offer)
 
 
 

Buy

Realtime data for MetaStock

     (special offer)
 
 
 
Formula Library
 
AmiBroker
MetaTrader
MetaStock
TradeStation
Wealth-Lab
NinjaTrader
 
add your formula
System Library
 
 
Account login
Your email:
Password:
 
Log in
New to s4t? Sign up.
If you forgot your password click here.
Search the Web
 
Custom Search

Cyclical MA Projection

Formula for: MetaStock

indicator


 

 

Views:  1390

Added: June 17, 2007
 
Rate this code:  Rate: 1 Rate: 2 Rate: 3 Rate: 4 Rate: 5
This formula has not been rated yet
 

email this link

 
 
Tags: MetaStock, indicator
 
Your Ad Here
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

 

 



Code:

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;


 






Author: Andrew Tomlinson
Source: EquisMetastock[at]yahoogroups[dot]com

 

View similar (indicator for MetaStock):

FibboGatto
CandleWeight
Divergence Indicator
Last Trough of MMA Convergence
Volume Accumulation Percentage
%f Oscillator
Squeeze Bollinger / Keltner / Momentum Indicator
Bollinger Band Width
Money Flow Index
Linear Regression Slope
...
 
 
all formulas for MetaStock
all formulas

 

 

Email to friend

Top

 

     
However we try to maintain hiqhest possible level of service - most formulas, oscillators, indicators
and systems are submitted by anonymous users.
Therefore S4T™ does not take any responsibility for it's quality.
If you use any of this information, use it at your own risk. You are responsible for your own trading decisions.
Be sure to verify that any information you see on these pages is correct, and is applicable to your particular trade.
In no case will S4T™ be responsible for your trading gains or losses.
 
Privacy note | (c) copyrights systems4trading.com 2006-2012