home *** CD-ROM | disk | FTP | other *** search
/ Shareware Overload / ShartewareOverload.cdr / busi / tas2091.zip / SELECT.TAS < prev    next >
Text File  |  1991-02-17  |  9KB  |  239 lines

  1. #OUTPUT_FILE 'select.lst'
  2. #MAX_QUOTES 200
  3.             Technical Analysis Scanner (TAS)
  4.             --------------------------------
  5.             TAS is a product of Martin Moore
  6.  
  7.    -----------------------------------------------------------------
  8.  
  9.    TAS Script Language (TASSL) is similar to PASCAL syntax. 
  10.    TAS has built-in TA functions and price arrays so that TASSL 
  11.    scripts can be created by the user to screen a Metastock(*) 
  12.    Data Directory (or directories) for stocks which match custom 
  13.    criteria. The rest of this file gives an example of a TASSL
  14.    script. This entire file is the input for the TAS program.
  15.  
  16.    (*) Metastock is a trademark of Equis International, Inc.
  17.    -----------------------------------------------------------------
  18.  
  19.    A few notes about syntax:                                      
  20.    -------------------------                                         }
  21.       {comment}    {- curly braces surround comments
  22.       a := b       - ':=' is used to assign 'b' to 'a'
  23.       * / - +      -  multiply, divide, subtract, add
  24.      ( expression) -  parentheses are used to guarantee order of
  25.                       evaluation is correct
  26.  
  27.       IF (x) THEN  - Conditions are tested with IF (cond) THEN true 
  28.          tstmt;      statement is executed. If (cond) is false, then
  29.       ELSE           the ELSE (if present) portion is executed
  30.          fstmt;      
  31.  
  32.    Predefined Values : Filled in when each MSP file is processed
  33.    --------------------------------------------------------------
  34.       TICKER      -  The 'ticker' symbol, e.g., AXP
  35.       FULLNAME    -  The 'full name', e.g., AMERICAN EXPRESS
  36.       O           -  The OPEN "data array"
  37.       H           -  The HIGH "data array"
  38.       L           -  The LOW  "data array"
  39.       C           -  The CLOSE "data array"
  40.       V           -  The VOLUME "data array"
  41.       OI          -  The OPEN INTEREST "data array"
  42.       P           -  The "last computed" array. For example, 
  43.                      X := MOV(C,30,'E')
  44.                      places the last day's 30day EMA in 'X' and
  45.                      the entire EMA array is in 'P' until another
  46.                      function is called.
  47.       P1          -  Secondary "last computed" array. For example,
  48.                      if X := MACD() is executed, 'P' contains the
  49.                      12day-26day EMA, and 'P1' contains the 9day EMA
  50.                      of the MACD.
  51.  
  52.          S A M P L E    T A S S L     S C R I P T
  53.   ---------------------  SELECT.scr ---------------------------
  54.  
  55.    This TASSL script contains the "Binary Wave" calculation
  56.    shown in the Metastock(*) 2.0 distribution system. It has been
  57.    modified to include the following indicators as well:
  58.                                     BUY         SELL
  59.       Chaikin's Oscillator          > 0         < 0
  60.       Commodity Channel Index      > 100       < -100
  61.       Linear Regression Plot       > close     < close   
  62.       
  63.    It is here to give an example of the kind of analysis 
  64.    available with the TASSL language.
  65.  
  66.    The Metastock manual discusses this binary wave system on 
  67.    page 187 of the User's Manual.
  68.  
  69.  
  70.    The script will put out a message if the value of the binary
  71.    wave changes from yesterday to today (the terms 'today' and
  72.    'yesterday' are used loosely, but meant to be the 'latest day'
  73.    and the 'day before', respectively). 
  74.  
  75.    Two variables are defined and updated as each of the four
  76.    individual binary wave formulas are checked. 
  77.    They are:
  78.  
  79.    "t_bwave" which is today's binary wave value (-6 to +6)
  80.             and
  81.    "y_bwave" which is yesterday's binary wave value (-6 to +6)
  82.  
  83.    What we are looking for is a TRANSITION from yesterday to
  84.    today. If the stock moved to +6 today and it was lower yesterday,
  85.    perhaps this is a buying opportunity. If the stock moved to -6
  86.    perhaps it is a short sell. 
  87.  
  88. }
  89. linear_plot : array;            { array for linear regression plot}
  90.  
  91. y_bwave := 0;     { this is our 'score' yesterday}
  92. t_bwave := 0;     { this is our 'score' today}
  93. {
  94.    First compute MACD Binary Wave for yesterday and today 
  95.  
  96.    Note that MACD() computes the 12 day EMA - 26 day EMA and places 
  97.    the result in the array 'p'. The 9 day EMA is computed at the same
  98.    time and placed in the result array 'p1'
  99. }
  100.  
  101. t_macd := macd();       { get today's macd value}
  102. y_macd := p[-1];        { get yesterday's macd value}
  103. t_macdtrigger := p1[0]; { result array 'p1' contains macd 'trigger'}
  104. y_macdtrigger := p1[-1];    { yesterday's macd trigger }
  105.  
  106. if t_macd > t_macdtrigger then 
  107.        t_bwave := t_bwave + 1;   { macd greater than trigger }
  108. else
  109.        t_bwave := t_bwave - 1;   { macd less than trigger    }
  110.  
  111. if y_macd > y_macdtrigger then 
  112.        y_bwave := y_bwave + 1;   { macd greater than trigger }
  113. else
  114.        y_bwave := y_bwave - 1;   { macd less than trigger    }
  115.  
  116. {
  117.    Now compute 20-MA B-Wave
  118. }
  119. t_ma20 := mov(c,20,'E');   { Compute 20 unit EMA of close }
  120. y_ma20 := p[-1];           { yesterday's EMA is in array 'p'}
  121.  
  122. if c[0] > t_ma20 then    { compare today's close to today's ema}
  123.        t_bwave := t_bwave + 1;   { ema greater than close }
  124. else
  125.        t_bwave := t_bwave - 1;   { ema less than close    }
  126.  
  127. if c[-1] > y_ma20 then    { compare yesterday's close to today's ema}
  128.        y_bwave := y_bwave + 1;   { ema greater than close }
  129. else
  130.        y_bwave := y_bwave - 1;   { ema less than close    }
  131.  
  132. {
  133.    Now compute 12-ROC B-Wave
  134. }
  135. t_roc12 := roc(c,12,'%');
  136. y_roc12 := p[-1];
  137.  
  138. if t_roc12 > 0 then
  139.        t_bwave := t_bwave + 1;   { roc greater than 0 }
  140. else
  141.        t_bwave := t_bwave - 1;   { roc less than 0    }
  142.  
  143. if y_roc12 > 0 then
  144.        y_bwave := y_bwave + 1;   { roc greater than 0 }
  145. else
  146.        y_bwave := y_bwave - 1;   { roc less than 0    }
  147.  
  148. {
  149.    Now compute 5-3 stochastic B-wave
  150. }
  151. t_sto := stoch(5,3);          { compute stoch(%K period, %K slow) }
  152. y_sto := p[-1];               { result in 'p' array again      }
  153.  
  154. if t_sto > 50 then
  155.        t_bwave := t_bwave + 1;   { stoch greater than 50 }
  156. else
  157.        t_bwave := t_bwave - 1;   { stoch less than 50    }
  158.  
  159. if y_sto > 50 then
  160.        y_bwave := y_bwave + 1;   { stoch greater than 50 }
  161. else
  162.        y_bwave := y_bwave - 1;   { stoch less than 50    }
  163.  
  164. {
  165.     check if Chaikin's AD oscillator is above or below 0
  166. }
  167. t_co := co();
  168. y_co := p[-1];
  169. t_bwave := t_bwave + (2 * (t_co > 0) - 1);
  170. y_bwave := y_bwave + (2 * (y_co > 0) - 1);
  171. {
  172.     check if CCI(14)  above +100 or below -100
  173. }
  174. t_cci := cci(14);
  175. y_cci := p[-1];
  176.  
  177. if t_cci < -100 then 
  178.    t_bwave := t_bwave - 1;
  179. else
  180. if t_cci > 100 then 
  181.    t_bwave := t_bwave + 1;
  182. if y_cci < -100 then 
  183.    y_bwave := y_bwave - 1;
  184. else
  185. if y_cci > 100 then 
  186.    y_bwave := y_bwave + 1;
  187. linear_plot := linreg(c,-51,-1); { compute linear regression line for
  188.                                   the last 50 days up to yesterday}
  189. if over(linear_plot,c) >= 0  then
  190.         y_bwave := y_bwave + 1;
  191. else
  192.         y_bwave := y_bwave - 1;
  193. linear_plot := linreg(c,-50,0); { compute linear regression line for
  194.                                   the last 50 days up to today}
  195. if over(linear_plot,c) >= 0  then
  196.         t_bwave := t_bwave + 1;
  197. else
  198.         t_bwave := t_bwave - 1;
  199. {
  200.    Okay, here we are at the end of the script. We have boiled
  201.    the seven formulas down to two values:
  202.    "t_bwave" which is today's binary wave value (-7 to +7)
  203.             and
  204.    "y_bwave" which is yesterday's binary wave value (-7 to +7)
  205.  
  206. }
  207.    First, let's check if the wave moved to +7..if so, let's print 
  208.    out it's value then and now
  209. }
  210. y_bwave := INT(y_bwave);   { make y_bwave into an INTEGER }
  211. t_bwave := INT(t_bwave);   { make t_bwave into an INTEGER }
  212. if FIRST_TICKER then
  213. begin
  214.     writeln('      \t        \t\t\t \tPRIOR\tCURRENT      ');
  215.     writeln('      \t        \t\t\t\tBINARY\t BINARY       ');
  216.     writeln('TICKER\t\tFULLNAME\t\t\t  WAVE\t   WAVE   CHANGE  ALERT');
  217. end;
  218. write(TICKER,'\t',fullname,'\t');
  219. diff := INT(t_bwave-y_bwave);
  220. write(y_bwave,'   ',t_bwave,'    ',diff);
  221. if ((y_bwave < 7) and (t_bwave = 7)) then
  222.     writeln('  **BUY**')
  223.    Now, let's check if the wave moved to -7..if so, let's print 
  224.    out it's value then and now
  225. }
  226. else
  227. if ((y_bwave > -7) and (t_bwave = -7)) then
  228.     writeln('  **SELL**')
  229. else
  230. begin
  231.     writeln(' ');
  232. end;   
  233. {-----------------END OF SELECT.TAS TASSL SCRIPT------------------}
  234.  
  235.  
  236.