AIQ is a part of Track Data Corporation (NASD symbol TRAC) www.trackdata.com


Example 4

This section is designed to give examples of an actual routine and an explanation of how of each part of the routine works.





 
 

 


 

This example will analyze the Scanany function and Cut operator(^) line by line.

  1) ! Scan back 10 days looking for the condition
  2) MyScan if ScanAny([close] = 40,10).
 

  3) ! Always run the rule first to set RuleDate, then compute the offest.
  4) ! Use the cut to erase the ruledate side effect but leave the
  5) ! number of days until rule fired intact.
  6) Offset is ^(MyScan then OffsetToDate(Month(),Day(),Year())).
 

  7) ! Run the rule MyScan, and make sure it is at least 4 days. 
  8) ! Do not leave any ruledate effects around
  9) Rule if ^(MyScan and (Offset > 4)).
10) Close is [close].

11) ! Close the day MyScan was met
12)
CloseOnRule is MyScan then close.

13) ! Close 4 days after MyScan
14)
Close4DaysLater is ValResult(close,Offset-4). 

Lines 1, 3,4,5,6,7,11,13,14 are comments. They are identified by exclamation marks. 

EDS will not process lines that start with an exclamation mark.

Line 2 is a rule. This line links a true/false value and a date with the rule name MyScan. This line uses the scanany function to find the first occurrence, looking back 10 days, for tickers that have a closing price equal to 40. It will also retain the date of the first occurrence.

Line 6 is a UDF. This line links the value of the difference of days between the date you ran the report and date the rule MyScan was true to the udf name Offset. It first resets the date with the Cut operator(^), next it checks to make sure the rule MyScan is true, then it returns the difference of days between the date you ran the report and date the rule MyScan was true.

Line 9 is a rule. This line links a true/false value with the rule name Rule.  The date is reset with the Cut operator(^),  then if the rule MyScan if true and the value of offset is greater than 4, Rule is true.

Line 10 is a UDF. This line links the value of today's close with the udf name Close.

Line 12 is a UDF. This line links the value of the close the day MyScan was true with the udf name CloseOnRule. Since this line doesn't use the Cut operator(^) CloseOnRule will return the value of the closing price on the day the rule MyScan was true. 

Line 14 is a UDF. This line links the value of the close 4 days after the day MyScan was true with the udf name Close4DaysLater. This line doesn't use the Cut operator(^) because the date was already reset for Offset. This line uses ValResult instead of Val to return the value of a UDF instead of a field. Offset is subtracted by four to return the value of the close 4 days after MyScan was true.