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

[EquisMetaStock Group] Re: Yearly % change



PureBytes Links

Trading Reference Links

John, to determine the correct last trading day of year for dates 
other than 31st Dec, would involve some hindsight code in MetaStock.

This hindsight-based code is part of the solution for the current 
MetaStock competition ( http://www.metastocktools.com/comp/comp-01.htm
 ), so I'll tackle this one after we have our second winner there.


> Also, if this were run in an exploration whose last date, for
> testing purposes, may be set to a prior year, will it still
> calculate the change based on the current year (currently 2005) or
> on the last date set in the exploration?

If you set the referenced indicator's default to a specific year, the 
exploration will return the yearly RoC% for only that specific year.


jose '-)
http://www.metastocktools.com




--- In equismetastock@xxxxxxxxxxxxxxx, "John Doe" <ms001122@xxxx> 
wrote:
>
> Jose,
> Some time back you posted the formula for calculating this year's %
> change:
> 
> { User inputs }
> yr:=Input("% change for Year [1800~2200]",
>   1800,2200,2000);
> yrNr:=Input("Year:  [1]Selected,  [2]All",
>   1,2,1);
> plot:=Input("plot:  [1]% Change,  [2]New Year markers",1,2,1);
> 
> { Start of year }
> init:=Cum(1)=2;
> nuYear:=Year()<>Ref(Year(),-1) OR init;
> 
> { Data Array }
> x:=C;
> 
> { Year's % change }
> ch:=(x/ValueWhen(1,nuYear,x)-1)*100;
> chYear:=If(Year()=yr,ch,0);
> chYear:=ValueWhen(1,chYear<>0 OR init,chYear);
> 
> { Select individual year's % or all }
> chPer:=If(yrNr=1,chYear,ch);
> 
> { Plot in own window }
> If(plot=1,chPer,nuYear)
> ------------------------------------------
> 
> There's an error in this as it calculates change from the Close of
> 1st trading day of this year, whereas by convention the yearly %
> change is always calculated from the last close of previous trading
> year. The error lies here:
> 
> ch:=(x/ValueWhen(1,nuYear,x)-1)*100;
> 
> as its using nuyear's value, not last year's. Can you fix this
> please?
> 
> Also, if this were run in an exploration whose last date, for
> testing purposes, may be set to a prior year, will it still
> calculate the change based on the current year (currently 2005) or
> on the last date set in the exploration?







------------------------ Yahoo! Groups Sponsor --------------------~--> 
Try Online Currency Trading with GFT. Free 50K Demo. Trade 
24 Hours. Commission-Free. 
http://us.click.yahoo.com/RvFikB/9M2KAA/U1CZAA/BefplB/TM
--------------------------------------------------------------------~-> 

 
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/