BullCharts Forum Homepage
Forum Home Forum Home > BullCharts > BullScript
  New Posts New Posts RSS Feed: Variable moving average
  FAQ FAQ  Forum Search   Calendar   Register Register  Login Login

Variable moving average

 Post Reply Post Reply
Author
Message
jalna View Drop Down
Regular
Regular


Joined: 31 Mar 2007
Posts: 95
Post Options Post Options   Quote jalna Quote  Post ReplyReply Direct Link To This Post Topic: Variable moving average
    Posted: 26 Mar 2009 at 10:51am
Can anyone write the code for this MA by Tushar Chande

Vidya 21, 5

This is the MetaStock code for VIDYA 21,5 which applies to the article "Breaking Out Of Price Channels" by Gerald Marisch in the TASC January 1998 edition.

Length:=Input("Length",1,200,21);
Smooth:=Input("Smoothing",1,200,5);
AbsCMO:=(Abs(CMO(C,Length)))/100;
SC:=2/(Smooth+1);
VIDYA:=If(Cum(1)<=(Length+1),C,(SC*AbsCMO*CLOSE)+(1-(SC*AbsCMO))*PREV);
VIDYA


Back to Top
maximo View Drop Down
BullCharts Guru
BullCharts Guru
Avatar

Joined: 02 Sep 2006
Location: Australia
Posts: 232
Post Options Post Options   Quote maximo Quote  Post ReplyReply Direct Link To This Post Posted: 27 Mar 2009 at 1:59am

Sure Jalna,

[Description="Tushar Chande's variable-length moving average (VIDYA)"]

[target=price; color=Magenta; width=2]

Length:=Input("Length",21,1);

Smooth:=Input("Smoothing",5,0);

AbsCMO:=(Abs(CMO(C,Length)))/100;

SC:=2/(Smooth+1);

VIDYA:=If(Cum(1)<=(Length+1),C,(SC*AbsCMO*CLOSE)+(1-(SC*AbsCMO))*PREV);

VIDYA



Edited by maximo - 27 Mar 2009 at 2:04am
Back to Top
jalna View Drop Down
Regular
Regular


Joined: 31 Mar 2007
Posts: 95
Post Options Post Options   Quote jalna Quote  Post ReplyReply Direct Link To This Post Posted: 27 Mar 2009 at 7:31am
Thanks Maximo yet again. What would we all do without you ?
I noticed in the formula that you have left out 200 in the first 2 lines. Was this not needed for the BC formula ?
Back to Top
maximo View Drop Down
BullCharts Guru
BullCharts Guru
Avatar

Joined: 02 Sep 2006
Location: Australia
Posts: 232
Post Options Post Options   Quote maximo Quote  Post ReplyReply Direct Link To This Post Posted: 27 Mar 2009 at 12:41pm
My guess is the 200 is a maximum value for the indicator and 1 would be the minimum.  No need to put limits on our settings :P
Back to Top
maximo View Drop Down
BullCharts Guru
BullCharts Guru
Avatar

Joined: 02 Sep 2006
Location: Australia
Posts: 232
Post Options Post Options   Quote maximo Quote  Post ReplyReply Direct Link To This Post Posted: 27 Mar 2009 at 1:12pm

I did a study of the CMO, Chande Momentum Oscillator myself (part of VIDYA), after having read Martin J. Pring's book 'Trading Systems Explained - How to build reliable technical systems' 

The CMO is a better oscillator for parcel splitting/scaling out than is RSI.   Due to it factoring in both upward and downward momentum at the same time.  So, it reaches the oversold and overbought regions more consistantly than RSI, but not more frequently.    In that book he explains how to use the oscillator with a simple moving average to profit from both  trending and ranging markets using a single method.    
 
Here's the CMO with a histogram and average applied to it.
 

[Description="CMOF - Filtered CMO, Max"]

n:=Input("Length",10,1);

momu:=If(C > Ref(C,-1),C - Ref(C,-1),0);

momd:=If(C < Ref(C,-1),Ref(C,-1) - C,0);

Momup:=momu / (1.75*Stdev(Abs(Typ()),n))*125;

Momdn:=momd / (1.75*Stdev(Abs(Typ()),n))*125;

CMOF:=100*((Sum(Momup,n)-Sum(Momdn,n))/(Sum(Momup,n)+Sum(Momdn,n)));

[color=blue; width=2]

CMOF;

[linestyle=solid; color=gold]

Sig:=Ma(CMOF,10,S);

Sig;

[Name=Histogram; linestyle=Histogram; color=crimson]

hst:=CMOF - Sig;

if(ma(hst,3) < ref(ma(hst,3),-1),hst,undefined);

[color=lime green]

if(ma(hst,3) > ref(ma(hst,3),-1),hst,undefined);



Edited by maximo - 27 Mar 2009 at 1:43pm
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down

Bulletin Board Software by Web Wiz Forums® version 9.69
Copyright ©2001-2010 Web Wiz