logo
Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

Options
Go to last post Go to first unread
ddharder  
#1 Posted : Wednesday, October 31, 2007 3:51:08 AM(UTC)
ddharder

Rank: Newbie

Groups: Registered, Registered Users
Joined: 10/31/2007(UTC)
Posts: 2

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

TIF

mstt  
#2 Posted : Wednesday, October 31, 2007 2:06:37 PM(UTC)
mstt

Rank: Advanced Member

Groups: Registered, Registered Users, Subscribers
Joined: 7/25/2005(UTC)
Views messages in topic : 1,042

Was thanked: 57 time(s) in 54 post(s)

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

ddharder  
#3 Posted : Saturday, November 3, 2007 8:31:53 AM(UTC)
ddharder

Rank: Newbie

Groups: Registered, Registered Users
Joined: 10/31/2007(UTC)
Posts: 2

Thanks Roy! This is great.
yonah1  
#4 Posted : Monday, December 31, 2007 5:17:42 PM(UTC)
yonah1

Rank: Member

Groups: Registered, Registered Users, Subscribers
Joined: 4/15/2007(UTC)
Posts: 14

mstt wrote:

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

Users browsing this topic
Guest (Hidden)
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.