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

Re: [EquisMetaStock Group] coding request



PureBytes Links

Trading Reference Links

Hi George
 
 
As Super has already said, Mark Pyle's GV DLL permits MetaStock to count events during an exploration. In order to do this DLL-based variables must be initialised prior to the main exploration. This can be accomplished with a purpose-built indicator or exploration (see the Reset scan below). Once counters are preset to zero an accumulating exploration reads the current accumulator value from the DLL, tests for the required condition and adds 0 or 1 to the read value, then stores the updated value back to the accumulator in the DLL. This process is then repeated for each of the remaining securities.
 
MetaStock can accumulate data serially, i.e. from one bar to the next in one security, but it cannot normally accumulate data from one date/bar across multiple securities. The GV DLL gets around this problem and allows the user to access a previously stored value for the CURRENT bar so that it can be updated to include new data pulled from the current security. A conventional MS formula cannot normally store the result of one calculation on one security and use that result with the next security. That's because all MS variables must be defined for each security scanned. However, GV DLL variables only need to be defined once and can then be accessed using Get or Set (read or write) by any security during the current MetaStock session.
 
The following two explorations give an example of how the GV DLL can be used to support a counter. The first exploration presets the CountU global variable to zero. As a convenience the stored day month and year can be read from the report in columns A, B and C. However it's the "Reset GV counter" code that's important ( A:=ExtFml("GV.SetVar","CountU",0); ). This line of code could just as easily reside in an indicator and be dropped onto a suitable index or security prior to running the "EMA Status Count Scan". When used as an indicator it must be deleted from the chart before running the scan. Otherwise the next chart refresh will again reset the DLL-based accumulator.
 
The main exploration adds 1 to the column A value each time the test _expression_ is TRUE. Depending on how your securities are sorted the report's ascending numbers may appear to be out of order. This occurs because processing and reporting order are not the same, i.e. one is in NAME order and the other is in SYMBOL order. Clicking the column A header takes care of that problem.
 
Notice that the date must be checked in the update logic of column A as well as in the filter. The filter is not processed until after all columns so without that check the GV variable would update regardless of whether or not the filter was subsequently activated.
 
 
Regards
 
Roy
 
 

 {EMA Status Count Reset}

 

 {Col A: Last Day}

 

 {Reset GV counter}

 A:=ExtFml("GV.SetVar","CountU",0);

 

 {Store last day parameter}

ExtFml("GV.SetVar","RunD",LastValue(DayOfMonth()));

 

 {Col B: LastMnth}

 {Store last month parameter}

ExtFml("GV.SetVar","RunM",LastValue(Month()));

 

 {Col C: LastYear}

 {Store last year parameter}

ExtFml("GV.SetVar","RunY",LastValue(Year()));

 

Filter enabled  No

Periodicity  Daily

Records required  500

 

 

 {EMA Status Count Scan}

 

 {ColA: Counter}

 {Count securities above 50-day EMA}

 

 {Date variables}

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

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

 

 {_expression_ to check against price}

MA:=Mov(C,50,E);

 

 {Count securities meeting test conditions}

Count:=LastValue(ExtFml("GV.GetVar","CountU"));

RunD:=ExtFml("GV.GetVar","RunD");

RunM:=ExtFml("GV.GetVar","RunM");

RunY:=ExtFml("GV.GetVar","RunY");

Date:=RunD=D AND RunM=M AND RunY=Y;

Test:=LastValue(Date AND C>MA AND V>0);

NewCount:=If(Test,{Then} Count+1,{Else} Count);

ExtFml("GV.SetVar","CountU",NewCount);

 

 {ColB: Status}

 {Mark securities above 50-day EMA}

 {Date variables}

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

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

 

 {_expression_ to check against price}

MA:=Mov(C,50,E);

 

 {Mark securities meeting test conditions}

RunD:=ExtFml("GV.GetVar","RunD");

RunM:=ExtFml("GV.GetVar","RunM");

RunY:=ExtFml("GV.GetVar","RunY");

Date:=RunD=D AND RunM=M AND RunY=Y;

LastValue(Date AND C>MA AND V>0);

 

 {Filter}

 {Discard if date or colB not matched}

RunD:=ExtFml("GV.GetVar","RunD");

RunM:=ExtFml("GV.GetVar","RunM");

RunY:=ExtFml("GV.GetVar","RunY");

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

RunD=D AND RunM=M AND RunY=Y AND colB;

  

Filter enabled  Yes

Periodicity  Daily

Records required  500

 
 
----- Original Message -----
Sent: Friday, May 09, 2008 1:17 AM
Subject: [EquisMetaStock Group] coding request

Hi,

Reg: Coding request.

The data I down load daily consists of O,H,L,C,V and open
interest. I would like to find out on a particular day how many
stocks have gone up / down compared to the previous day. In the
explorer, in column A I had entered C>REF(C,-1). This shows me all
the stocks that have gone up compared to the previous day
(represented by 1 and 0). Now, comes the real problem.

In column A there are over 1800 stocks. In this column there
are hundreds of 1s and 0s. Instead of manually counting all the 1s
and 0s, is there any way to get the total of all the 1s and 0s (that
is, the total number of stocks that have gone up / down). I have
tried using CUM() AND SUM() functions but nothing seems to work. Can
any one please help me to get the answer?

Thanks,

George



__________ NOD32 3084 (20080508) Information __________

This message was checked by NOD32 antivirus system.
http://www.eset.com
__._,_.___

Your email settings: Individual Email|Traditional
Change settings via the Web (Yahoo! ID required)
Change settings via email: Switch delivery to Daily Digest | Switch to Fully Featured
Visit Your Group | Yahoo! Groups Terms of Use | Unsubscribe

__,_._,___