in Search

52-Week High

Last post 12-31-2007, 17:17 by yonah1. 3 replies.
Sort Posts: Previous Next
  •  10-31-2007, 3:51 25648

    52-Week High

    I need to build an Explorer scan that finds all stocks trading within 5% of their 52-week highs. 

    TIF

  •  10-31-2007, 14:06 25656 in reply to 25648

    Re: 52-Week High

    Hi ddharder

     

    The first of these explorations checks for the current HIGH being 5% or less away from the 1-year highest HIGH. The second checks for the current CLOSE being 5% or less away from the 1-year highest CLOSE. Securities with less than 1 year of history will not return a result unless the commented additional "Start" definition is enabled. The exploration looks back to the previous "anniversary" of the current date and begins its check for new highs from the first bar following that anniversary.

     

    Notice that the result line includes a check for valid volume. Obviously this might need to be altered for securities not including volume. What these explorations do not do is validate the last bar of data as being for the current date. Explorations for new 1-year highs included with the October issue of MSTT did have a date checking mechanism to eliminate false new highs from securities that did not trade on the current date.

     

     

     {ColA: NewHighH}

     {Mark new 1-year highest HIGH}

     {Date variables}

    D:=DayOfMonth(); M:=Month(); Y:=Year();

    LD:=LastValue(D); LM:=LastValue(M);

    D1:=Ref(D,-1); M1:=Ref(M,-1); Y1:=Ref(Y,-1);

    A:=(Y>Y1+1 OR (Y>Y1)*(M>M1 OR (M=M1)*(D>=D1)));

    A:=ExtFml("Forum.Sum",A,1);

     

     {1-year highest HIGHs}

    G:=M*31+D-372*(M>LM OR (M=LM AND D>LD))-372*A;

    Start:=ExtFml("Forum.Sum",G<ValueWhen(2,1,G),1);

     {Start:=Start OR Cum(IsDefined(Start))=1;}

    HH:=HighestSince(1,Start,H);

     

     {Mark securities meeting test conditions}

    H>=Ref(HH,-1)*0.95 AND V>0;

     

     {Filter}

    colA

     

     

     {ColA: NewHighC}

     {Mark new 1-year highest CLOSE}

     {Date variables}

    D:=DayOfMonth(); M:=Month(); Y:=Year();

    LD:=LastValue(D); LM:=LastValue(M);

    D1:=Ref(D,-1); M1:=Ref(M,-1); Y1:=Ref(Y,-1);

    A:=(Y>Y1+1 OR (Y>Y1)*(M>M1 OR (M=M1)*(D>=D1)));

    A:=ExtFml("Forum.Sum",A,1);

     

      {1-year highest CLOSE}

    G:=M*31+D-372*(M>LM OR (M=LM AND D>LD))-372*A;

    Start:=ExtFml("Forum.Sum",G<ValueWhen(2,1,G),1);

    {Start:=Start OR Cum(IsDefined(Start))=1;}

    HC:=HighestSince(1,Start,C);

     

      {Mark securities meeting test conditions}

    C>=Ref(HC,-1)*0.95 AND V>0;

     

     {Filter}

    colA

     

     

    Hope this helps

     

    Roy

    MetaStock Tips & Tools

     

  •  11-03-2007, 8:31 25677 in reply to 25656

    Re: 52-Week High

    Thanks Roy!  This is great.
  •  12-31-2007, 17:17 26199 in reply to 25656

    Re: 52-Week High

    mstt:

    Hi ddharder

     

    The first of these explorations checks for the current HIGH being 5% or less away from the 1-year highest HIGH. The second checks for the current CLOSE being 5% or less away from the 1-year highest CLOSE. Securities with less than 1 year of history will not return a result unless the commented additional "Start" definition is enabled. The exploration looks back to the previous "anniversary" of the current date and begins its check for new highs from the first bar following that anniversary.

     

    Notice that the result line includes a check for valid volume. Obviously this might need to be altered for securities not including volume. What these explorations do not do is validate the last bar of data as being for the current date. Explorations for new 1-year highs included with the October issue of MSTT did have a date checking mechanism to eliminate false new highs from securities that did not trade on the current date.

     

     

     {ColA: NewHighH}

     {Mark new 1-year highest HIGH}

     {Date variables}

    D:=DayOfMonth(); M:=Month(); Y:=Year();

    LD:=LastValue(D); LM:=LastValue(M);

    D1:=Ref(D,-1); M1:=Ref(M,-1); Y1:=Ref(Y,-1);

    A:=(Y>Y1+1 OR (Y>Y1)*(M>M1 OR (M=M1)*(D>=D1)));

    A:=ExtFml("Forum.Sum",A,1);

     

     {1-year highest HIGHs}

    G:=M*31+D-372*(M>LM OR (M=LM AND D>LD))-372*A;

    Start:=ExtFml("Forum.Sum",G<ValueWhen(2,1,G),1);

     {Start:=Start OR Cum(IsDefined(Start))=1;}

    HH:=HighestSince(1,Start,H);

     

     {Mark securities meeting test conditions}

    H>=Ref(HH,-1)*0.95 AND V>0;

     

     {Filter}

    colA

     

     

     {ColA: NewHighC}

     {Mark new 1-year highest CLOSE}

     {Date variables}

    D:=DayOfMonth(); M:=Month(); Y:=Year();

    LD:=LastValue(D); LM:=LastValue(M);

    D1:=Ref(D,-1); M1:=Ref(M,-1); Y1:=Ref(Y,-1);

    A:=(Y>Y1+1 OR (Y>Y1)*(M>M1 OR (M=M1)*(D>=D1)));

    A:=ExtFml("Forum.Sum",A,1);

     

      {1-year highest CLOSE}

    G:=M*31+D-372*(M>LM OR (M=LM AND D>LD))-372*A;

    Start:=ExtFml("Forum.Sum",G<ValueWhen(2,1,G),1);

    {Start:=Start OR Cum(IsDefined(Start))=1;}

    HC:=HighestSince(1,Start,C);

     

      {Mark securities meeting test conditions}

    C>=Ref(HC,-1)*0.95 AND V>0;

     

     {Filter}

    colA

     

     

    Hope this helps

     

    Roy

    MetaStock Tips & Tools

     

     

    Roy,

     

    I tried to put the above code in Metastock, but get the following message when I try to save:

    "This DLL does not exist in the MSX DLL folder."  I think it is referring to: A:=ExtFml("Forum.Sum",A,1).

    I am just learning Metastock.  Where do I find the needed DLL?

    Thanks

View as RSS news feed in XML