in Search

How do I get Quarterly Start date?

Last post 05-15-2007, 2:09 by Jose. 3 replies.
Sort Posts: Previous Next
  •  01-06-2007, 1:26 22388

    How do I get Quarterly Start date?

    { User input }
    type:=Input("OHLC values: [1]Day, [2]Week, [3]Month, [4]Year",1,4,1);

    { Day's start }
    DayStart:=DayOfMonth()<>Ref(DayOfMonth(),-1);

    { Week's start - reference "Calendar Week
     counter" indicator for accurate weekly signals}
    WkStart:=DayOfWeek()<Ref(DayOfWeek(),-1);

    { Month's start }
    MthStart:=Month()<>Ref(Month(),-1);

    { Year's start }
    YrStart:=Year()>Ref(Year(),-1);        <---- Instead of Yearly, I want to get quarterly ???

    { Selected Daily/Weekly/Monthly/Yearly }
    start1:=If(type=1,DayStart,
     If(type=2,WkStart,
     If(type=3,MthStart,YrStart)));
    start:=start1 OR Cum(1)=2;
  •  01-08-2007, 20:17 22432 in reply to 22388

    Re: How do I get Quarterly Start date?

    Vultran

     

     

    The first month of any quarter can be found by dividing (Month()-1) by 3 and testing the fractional result for zero..

     

    Qstart:=Frac((Month()-1)/3)=0;

     

    The first bar or leading edge of the first month in each quarter is then found by testing the current bar for TRUE (Qstart) and the previous bar for FALSE (Qstart=0). The use of either Alert() or ValueWhen() is preferable to Ref() when testing the logical state of the previous bar for the simple reason that my suggested alternatives do not imbed an N/A bar on bar one. To be fair, though, neither Alert() nor ValueWhen() can produce a result on bar one either

     

    Qstart AND Alert(Qstart=0,2);

     

    Qstart:=Frac((Month()-1)/3)=0;

    Qstart {=TRUE} AND Alert(Qstart=FALSE,2);

     

    Variations on the theme are as follows.

     

    Qstart:=Frac((Month()-1)/3)=0;

    Qstart * Alert(Qstart=0,2);

     

    Qstart:=Frac((Month()-1)/3)=0;

    Qstart AND ValueWhen(2,1,Qstart)=0;

     

    Qstart:=Frac((Month()-1)/3)=0;

    Qstart * Ref(Qstart,-1)=0; {NOT recommended}

     

     

    Roy

    MetaStock Tips & Tools

  •  05-14-2007, 16:53 24043 in reply to 22432

    Re: How do I get Quarterly Start date?

    Mr. Larson, you have a nice newsletter. Smile [:)]



    Bob
  •  05-15-2007, 2:09 24046 in reply to 24043

    Re: How do I get Quarterly Start date?

    Vutran320, to avoid plagiarism and copyright issues, please kindly include the original formula complete with copyright headers when posting copyright material in the public domain.

    Thank you.


    jose
    MetaStockTools.com
View as RSS news feed in XML