in Search

Yearly RoC

Last post 12-31-2005, 1:54 by Jose. 8 replies.
Sort Posts: Previous Next
  •  11-26-2005, 4:18 11896

    Yearly RoC

    This MS indicator plots the Rate of Change (RoC) for each year, resetting to zero (% or $) at the beginning of each year.
    It may be useful for comparing markedly different charts, using the default % change option.

    If there is a demand for it, I'll consider coding a monthly version of the same.


    Code:

    MetaStock -> Tools -> Indicator Builder -> New ->
    Copy and paste complete formula between "---8<---" lines.

    ==========
    Yearly RoC
    ==========
    ---8<-----------------------------

    { Yearly Rate of Change (RoC) v2.0

    ©Copyright 2004~2005 Jose Silva.
    The grant of this license is for personal use
    only - no resale or repackaging allowed.
    All code remains the property of Jose Silva.
    http://www.metastocktools.com }

    { User inputs }
    method:=Input("Method: [1]%percent, [2]$points",1,2,1);
    yr:=Input("RoC for Year [1800~2200]",
    1800,2200,2005);
    yrNr:=Input("Year's RoC: [1]Selected, [2]All",
    1,2,2);
    plot:=Input("plot: [1]RoC, [2]New Year signals",1,2,1);

    { Start of year }
    init:=Cum(1)=2;
    nuYear:=Year()<>Ref(Year(),-1) OR init;

    { Data Array }
    x:=C;

    { Year's % RoC change }
    chPer:=(x/ValueWhen(1,nuYear,x)-1)*100;

    { Year's $ RoC change }
    chPts:=x-ValueWhen(1,nuYear,x);

    { Select %/$ RoC method }
    ch:=If(method=1,chPer,chPts);

    { Restrict RoC to selected year }
    chYear:=If(Year()=yr,ch,0);
    chYear:=ValueWhen(1,chYear<>0 OR init,chYear);

    { Select individual year's RoC or all years }
    chPer:=If(yrNr=1,chYear,ch);

    { Plot in own window }
    If(plot=1,chPer,nuYear)

    ---8<-----------------------------




    jose '-)
    MetaStockTools.com
  •  11-27-2005, 8:47 11929 in reply to 11896

    Year's Hi/Lo

    Related to the above, this indicator plots the (selected or all) year's High & Lows:

    Code:


    MetaStock -> Tools -> Indicator Builder -> New ->
    Copy and paste complete formula between "---8<---" lines.

    ============
    Year's Hi/Lo
    ============
    ---8<-----------------------------

    { Yearly High & Low v2.0

    ©Copyright 2005 Jose Silva.
    The grant of this license is for personal use
    only - no resale or repackaging allowed.
    All code remains the property of Jose Silva.
    http://www.metastocktools.com }

    { User inputs }
    yr:=Input("Year [1800~2200]",1800,2200,2004);
    yrNr:=Input("Year: [1]Selected, [2]All",
    1,2,2);
    plot:=Input("[1]Year's Hi/Lo, [2]NewYear signals",1,2,1);

    { Start of year }
    init:=Cum(1)=2;
    nuYear:=Year()<>Ref(Year(),-1) OR init;

    { Highest/Lowest of year }
    YearHi:=HighestSince(1,nuYear,H);
    YearLo:=LowestSince(1,nuYear,L);

    { Restrict High to selected year }
    xYrHi:=If(Year()=yr,YearHi,0);
    xYrHi:=If(Year()>=yr,xYrHi,C);
    xYrHi:=ValueWhen(1,xYrHi>0,xYrHi);

    { Restrict Low to selected year }
    xYrLo:=If(Year()=yr,YearLo,0);
    xYrLo:=If(Year()>=yr,xYrLo,C);
    xYrLo:=ValueWhen(1,xYrLo>0,xYrLo);

    { Select: individual year's Hi/Lo or all years }
    pYrHi:=If(yrNr=1,xYrHi,YearHi);
    pYrLo:=If(yrNr=1,xYrLo,YearLo);

    { Plot on price chart }
    If(plot=1,pYrHi,0);
    If(plot=1,pYrLo,nuYear)

    ---8<-----------------------------




    jose '-)
    MetaStockTools.com
  •  11-28-2005, 15:26 11960 in reply to 11896

    Re: Year's Hi/Lo

    May be a good way to select stocks to look at in a first run of an explorer. will have to play around with it.
    I have used this years H,L,C compared with last years H,L as a first run of an explorer to select stocks I
    want to look at,
    with this code I should be able to combine into one indicator like you have done.
    Thanks.
  •  11-28-2005, 23:42 12016 in reply to 11896

    Re: Year's Hi/Lo

    Hey Joes
    Do you have indicator that show Quoter(qtr) Rate of Change (RoC) or Half year (ROC) I want to get indicator to see how stock change from last quoter to present day or last half year to present day

    Best Regard
    konrad
  •  11-29-2005, 5:59 12033 in reply to 11896

    Re: Year's Hi/Lo

    Konrad, coding/testing indicators take up valuable time - my fee for specific custom work is the same as Equis' @ US$60/hr.

    However, if I find a strong demand for this function, I'll then consider coding it here.


    jose '-)
    MetaStockTools.com
  •  12-23-2005, 19:12 13279 in reply to 11896

    Yearly Rate of Change (RoC) v3.0

    This indicator code update deals with the difficult issue of finding the correct closing price of the year.

    Code:

    MetaStock -> Tools -> Indicator Builder -> New ->
    Copy and paste complete formula between "---8<---" lines.


    ==========
    Yearly RoC
    ==========
    ---8<-----------------------------

    { Yearly Rate of Change (RoC) v3.0

    ©Copyright 2004~2006 Jose Silva.
    The grant of this license is for personal use
    only - no resale or repackaging allowed.
    All code remains the property of Jose Silva.
    http://www.metastocktools.com }

    { User inputs }
    method:=Input("Method: [1]%percent, [2]$points",1,2,1);
    yr:=Input("RoC for Year [1800~2200]",
    1800,2200,2004);
    yrNr:=Input("Year's RoC: [1]Selected, [2]All",
    1,2,2);
    plot:=Input("plot: [1]RoC, [2]Year signals",
    1,2,1);

    { Start/End of year }
    nuYear:=Year()<>Ref(Year(),-1) OR Cum(1)=2;
    YearEnd:=PeakBars(1,
    -(nuYear OR Cum(IsDefined(nuYear))=1),1)=0;
    init:=Cum(IsDefined(YearEnd))=1;

    { Data Array }
    x:=C;

    { Year's $ RoC change }
    chPts:=x-ValueWhen(1,YearEnd,x);
    chPts:=If(YearEnd=0,chPts,
    Ref(chPts,-1)+x-Ref(x,-1));

    { Year's % RoC change }
    chPer:=(x/ValueWhen(1,YearEnd,x)-1)*100;
    chPer:=If(YearEnd=0,chPer,
    Ref(chPer,-1)+(x/Ref(x,-1)-1)*100);

    { Select %/$ RoC method }
    ch:=If(method=1,chPer,chPts);

    { Restrict RoC to selected year }
    chYear:=If(Year()=yr,ch,0);
    chYear:=If(Year()=yr,chYear,
    ValueWhen(1,
    init OR YearEnd AND Year()=yr,chYear));

    { Select individual year's RoC or all years }
    chPer:=If(yrNr=1,chYear,ch);

    { Plot in own window }
    If(plot=1,chPer,nuYear-YearEnd)

    ---8<-----------------------------




    jose '-)
    MetaStockTools.com
  •  12-23-2005, 22:49 13281 in reply to 11896

    Yearly Rate of Change (RoC) v4.0

    This updated indicator now includes historical as well as yearly RoC plots.

    Code:

    ==========
    Yearly RoC
    ==========
    ---8<-----------------------------

    { Yearly Rate of Change (RoC) v4.0

    ©Copyright 2004~2006 Jose Silva.
    The grant of this license is for personal use
    only - no resale or repackaging allowed.
    All code remains the property of Jose Silva.
    http://www.metastocktools.com }

    { User inputs }
    method:=Input("Method: [1]%percent, [2]$points",1,2,1);
    yr:=Input("RoC for Year [1800~2200]",
    1800,2200,2004);
    yrNr:=Input("Yearly RoC: [1]Year, [2]Yearly, [3]Historical",1,3,2);
    plot:=Input("plot: [1]RoC, [2]Year signals",
    1,2,1);

    { Start/End of year }
    nuYear:=Year()<>Ref(Year(),-1) OR Cum(1)=2;
    YearEnd:=PeakBars(1,
    -(nuYear OR Cum(IsDefined(nuYear))=1),1)=0;
    init:=Cum(IsDefined(YearEnd))=1;

    { Data Array }
    x:=C;

    { Yearly $ RoC change }
    chPts:=x-ValueWhen(1,YearEnd,x);
    chPts:=If(YearEnd=0,chPts,
    Ref(chPts,-1)+x-Ref(x,-1));

    { Yearly % RoC change }
    chPer:=(x/ValueWhen(1,YearEnd,x)-1)*100;
    chPer:=If(YearEnd=0,chPer,
    Ref(chPer,-1)+(x/Ref(x,-1)-1)*100);

    { Select %/$ RoC method }
    ch:=If(method=1,chPer,chPts);

    { Restrict RoC to selected year }
    chYear:=If(Year()=yr,ch,0);
    chYear:=If(Year()=yr,chYear,
    ValueWhen(1,
    init OR YearEnd AND Year()=yr,chYear));

    { Historical RoC from beginning of chart }
    chAllPts:=x-ValueWhen(1,Cum(1)=1,x);
    chAllPer:=(x/ValueWhen(1,Cum(1)=1,x)-1)*100;

    { Select %/$ historical RoC method }
    chAll:=If(method=1,chAllPer,chAllPts);

    { Select type of Yearly RoC }
    YearRoc:=If(yrNr=1,chYear,If(yrNr=2,ch,chAll));

    { Plot in own window }
    If(plot=1,YearRoc,nuYear-YearEnd)

    ---8<-----------------------------




    jose '-)
    MetaStockTools.com
  •  12-25-2005, 7:36 13313 in reply to 11896

    Yearly Rate of Change (RoC) v4.1

    This version now also plots RoC on the first incomplete year of data.

    Code:

    ==========
    Yearly RoC
    ==========
    ---8<-----------------------------

    { Yearly Rate of Change (RoC) v4.1

    Note:
    First incomplete year plots RoC from 4th bar.

    ©Copyright 2004~2006 Jose Silva.
    The grant of this license is for personal use
    only - no resale or repackaging allowed.
    All code remains the property of Jose Silva.
    http://www.metastocktools.com }

    { User inputs }
    method:=Input("Method: [1]%percent, [2]$points",1,2,1);
    yr:=Input("RoC for Year [1800~2200]",
    1800,2200,2004);
    yrNr:=Input("Yearly RoC: [1]Year, [2]Yearly, [3]Historical",1,3,2);
    plot:=Input("plot: [1]RoC, [2]Year signals",
    1,2,1);

    { Start/End of year }
    nuYear:=Year()<>Ref(Year(),-1) OR Cum(1)=2;
    YearEnd:=PeakBars(1,-(nuYear OR
    Cum(IsDefined(nuYear))=1 OR Cum(1)=4),1)=0;
    init:=Cum(IsDefined(YearEnd))=1;

    { Data Array }
    x:=C;

    { Yearly $ RoC change }
    chPts:=x-ValueWhen(1,YearEnd,x);
    chPts:=If(YearEnd=0,chPts,
    Ref(chPts,-1)+x-Ref(x,-1));

    { Yearly % RoC change }
    chPer:=(x/ValueWhen(1,YearEnd,x)-1)*100;
    chPer:=If(YearEnd=0,chPer,
    Ref(chPer,-1)+(x/Ref(x,-1)-1)*100);

    { Select %/$ RoC method }
    ch:=If(method=1,chPer,chPts);

    { Restrict RoC to selected year }
    chYear:=If(Year()=yr,ch,0);
    chYear:=If(Year()=yr,chYear,
    ValueWhen(1,
    init OR YearEnd AND Year()=yr,chYear));

    { Historical RoC from beginning of chart }
    chAllPts:=x-ValueWhen(1,Cum(1)=1,x);
    chAllPer:=(x/ValueWhen(1,Cum(1)=1,x)-1)*100;

    { Select %/$ historical RoC method }
    chAll:=If(method=1,chAllPer,chAllPts);

    { Select type of Yearly RoC }
    YearRoc:=If(yrNr=1,chYear,If(yrNr=2,ch,chAll));

    { Plot in own window }
    If(plot=1,YearRoc,nuYear-YearEnd)

    ---8<-----------------------------




    jose '-)
    MetaStockTools.com
  •  12-31-2005, 1:54 13459 in reply to 11896

    RoC % for year 2005

    How well did your market perform in 2005?


    Code:

    RoC % for year 2005
    -------------------

    Indices
    -------
    +40.2% Nikkei 225
    +27.1% DAX
    +23.4% CAC 40
    +17.6% ASX 200
    +16.7% FTSE 100
    +7.0% NYSE Composite
    +4.5% Hang Seng
    +3.0% S&P 500
    +1.4% Nasdaq Composite
    -0.5% Dow Jones


    Commodities
    -----------
    +40.5% Crude Oil
    +15.1% Wheat (Kansas)
    +13.8% Gold


    Currencies/USD$
    ---------------
    +3.5% Canadian $
    -6.0% Australian $
    -10.1% British Pound
    -12.5% Euro
    -12.7% Japanese Yen




    jose '-)
    MetaStockTools.com
View as RSS news feed in XML