home *** CD-ROM | disk | FTP | other *** search
/ The World of Computer Software / World_Of_Computer_Software-02-387-Vol-3of3.iso / t / tas501.zip / SELCT.TAS < prev    next >
Text File  |  1993-02-25  |  8KB  |  204 lines

  1. #TITLE Script to compute 6 point binary wave and show change          
  2. #MAX_QUOTES 200
  3. #OUTPUT_FILE 'SELECT.LST'
  4. SHOW_ALL equal to zero if you only want to show BUY/SELL SIGNALS
  5. }
  6. SHOW_ALL = 1;            
  7.  
  8. {
  9.   ---------------------  STUDY1.scr ---------------------------
  10.    This script contains the "Achelis Binary Wave(tm)" calculation
  11.    shown in the Metastock(*) 2.0 distribution system. It has been
  12.    modified to include the following indicators as well:
  13.                                     BUY         SELL
  14.       Chaikin's Oscillator          > 0         < 0
  15.       Commodity Channel Index      > 100       < -100
  16.    It is here to give an example of the kind of analysis
  17.    available with the TAS Script language.
  18.    The Metastock manual discusses this binary wave system on
  19.    page 187 of the User's Manual.
  20.    The script will put out a message if the value of the binary
  21.    wave changes from yesterday to today (the terms 'today' and
  22.    'yesterday' are used loosely, but meant to be the 'latest day'
  23.    and the 'day before', respectively).
  24.    Two variables are defined and updated as each of the four
  25.    individual binary wave formulas are checked.
  26.    They are:
  27.    "t_bwave" which is today's binary wave value (-6 to +6)
  28.             and
  29.    "y_bwave" which is yesterday's binary wave value (-6 to +6)
  30.    What we are looking for is a TRANSITION from yesterday to
  31.    today. If the stock moved to +6 today and it was lower yesterday,
  32.    perhaps this is a buying opportunity. If the stock moved to -6
  33.    perhaps it is a short sell.
  34. }
  35. y_total : number;        { yesterday's total bwave }
  36. t_total : number;        { today's total bwave value }
  37. c_total : number;        { total changed bwave values}
  38. tick_total : number;     { ticker count }
  39. sell_count : number;     { total SELL's given }
  40. buy_count : number;      { total BUY's given }
  41. MACD_ARRAY : ARRAY;    { Place to put values for TODAY }
  42. MACDTRIG_ARRAY : ARRAY;
  43. MA20 : ARRAY;
  44. ROC12 : ARRAY;           { PLACE TO PUT RATE OF CHANGE }
  45. STOCH53 : ARRAY;                { PLACE TO PUT STOCH(5,3) VALUES }
  46. CO_ARRAY : ARRAY;
  47. CCI14 : ARRAY;          { PLACE TO PUT CCI(14) VALUES }
  48. y_bwave := 0;     { this is our 'score' yesterday}
  49. t_bwave := 0;     { this is our 'score' today}
  50. alert   := '         ';
  51. if FIRST_TICKER then
  52. begin
  53.     good_date = dates[0];   { check's for files not current }
  54.     writeln('                         --BINARY WAVE--        ');
  55.     writeln('TICKER  FULLNAME         PRIOR CURR  CHNG  ALERT    CLOSE');
  56.     y_total = 0;        { yesterday's total bwave }
  57.     t_total = 0;        { today's total bwave value }
  58.     c_total = 0;        { total changed bwave values}
  59.     tick_total = 0;     { ticker count }
  60.     sell_count = 0;     { SELL count }
  61.     buy_count = 0;      { BUY count }
  62. end;
  63. { SKIP any tickers which are not 'up-to-date'}
  64. if good_date = dates[0] then
  65. BEGIN
  66.     {
  67.        First compute MACD Binary Wave for yesterday and today
  68.        Note that MACD() computes the 12 day EMA - 26 day EMA and places
  69.        the result in the array MACD_ARRAY. The 9 day EMA is computed
  70.        and placed in the result array MACDTRIG_ARRAY
  71.     }
  72.     MACD_ARRAY = MACD();
  73.     MACDTRIG_ARRAY = MACDTRIGGER();
  74.     {
  75.        Now compute 20-MA B-Wave
  76.     }
  77.     MA20 := mov(c,20,'E');   { Compute 20 unit EMA of close }
  78.     {
  79.        Now compute 12-ROC B-Wave
  80.     }
  81.     ROC12 := roc(c,12,'%');
  82.     {
  83.        Now compute 5-3 stochastic B-wave
  84.     }
  85.     STOCH53 := stoch(5,3);          { compute stoch(%K period, %K slow) }
  86.     {
  87.         check if Chaikin's AD oscillator is above or below 0
  88.     }
  89.     CO_ARRAY := CO();       { PLACE CHAIKIN'S OSCILLATOR IN CO_ARRAY}
  90.     {
  91.         check if CCI(14)  above +100 or below -100
  92.     }
  93.     CCI14 := cci(14);
  94.  
  95.    { All arrays are calculated. Now do the checking of change }
  96.     IF MACD_ARRAY[0] > MACDTRIG_ARRAY[0] THEN
  97.        t_bwave := t_bwave + 1    { macd greater than trigger }
  98.     else
  99.        t_bwave := t_bwave - 1;   { macd less than trigger    }
  100.     if MACD_ARRAY[-1] > MACDTRIG_ARRAY[-1] then
  101.        y_bwave := y_bwave + 1    { macd greater than trigger }
  102.     else
  103.        y_bwave := y_bwave - 1;   { macd less than trigger    }
  104.     if c[0] > MA20 then    { compare today's close to today's ema}
  105.        t_bwave := t_bwave + 1    { ema greater than close }
  106.     else
  107.        t_bwave := t_bwave - 1;   { ema less than close    }
  108.     if c[-1] > MA20[-1] then    { compare yesterday's close to today's ema}
  109.        y_bwave := y_bwave + 1    { ema greater than close }
  110.     else
  111.        y_bwave := y_bwave - 1;   { ema less than close    }
  112.     if ROC12 > 0 then
  113.        t_bwave := t_bwave + 1    { roc greater than 0 }
  114.     else
  115.        t_bwave := t_bwave - 1;   { roc less than 0    }
  116.     if ROC12[-1] > 0 then
  117.        y_bwave := y_bwave + 1    { roc greater than 0 }
  118.     else
  119.        y_bwave := y_bwave - 1;   { roc less than 0    }
  120.     if STOCH53[0] > 50 then
  121.        t_bwave := t_bwave + 1    { stoch greater than 50 }
  122.     else
  123.        t_bwave := t_bwave - 1;   { stoch less than 50    }
  124.     if STOCH53[-1] > 50 then
  125.        y_bwave := y_bwave + 1    { stoch greater than 50 }
  126.     else
  127.            y_bwave := y_bwave - 1;   { stoch less than 50    }
  128.     IF CO_ARRAY[0] > 0 THEN
  129.         t_bwave := t_bwave + 1
  130.     else
  131.         t_bwave := t_bwave - 1;
  132.     IF CO_ARRAY[-1] > 0 THEN
  133.         y_bwave := y_bwave + 1
  134.     else
  135.         y_bwave := y_bwave - 1;
  136.     if CCI14[0] < -100 then
  137.        t_bwave := t_bwave - 1
  138.     else
  139.     if CCI14[0] > 100 then
  140.        t_bwave := t_bwave + 1;
  141.     if CCI14[-1] < -100 then
  142.        y_bwave := y_bwave - 1
  143.     else
  144.     if CCI14[-1] > 100 then
  145.        y_bwave := y_bwave + 1;
  146.     {
  147.        Okay, here we are at the end of the script. We have boiled
  148.        the formulas down to two values:
  149.        "t_bwave" which is today's binary wave value (-6 to +6)
  150.                 and
  151.        "y_bwave" which is yesterday's binary wave value (-6 to +6)
  152.     }
  153.     {
  154.        First, let's check if the wave moved to +6..if so, let's print
  155.        out it's value then and now
  156.     }
  157.     y_bwave := INT(y_bwave);   { make y_bwave into an INTEGER }
  158.     t_bwave := INT(t_bwave);   { make t_bwave into an INTEGER }
  159.     diff := INT(t_bwave-y_bwave);
  160.     tick_total = tick_total + 1;    { add to count of tickers }
  161.     y_total = y_total + y_bwave;    { add yesterday's bwave to total}
  162.     t_total = t_total + t_bwave;    { add today's bwave to total}
  163.     c_total = c_total + diff;    { add diff in bwave to total}
  164.     buy_flag = 0;
  165.     sell_flag = 0;
  166.     alert = '         ';
  167.     if ((y_bwave < 6) and (t_bwave = 6)) then
  168.     begin
  169.         buy_flag = 1;
  170.         alert = '   BUY   ';
  171.         buy_count = buy_count + 1;
  172.     end
  173.     {
  174.        Now, let's check if the wave moved to -6..if so, let's print
  175.        out it's value then and now
  176.     }
  177.     else
  178.     if ((y_bwave > -6) and (t_bwave = -6)) then
  179.     begin
  180.         sell_flag =  1;
  181.         alert = '   SELL  ';
  182.         sell_count = sell_count + 1;
  183.     end;
  184.     if (show_all = 1) or (buy_flag = 1) or (sell_flag = 1) then
  185.     begin
  186.        { Write out the line with the current alert }
  187.        write(TICKER,fullname,' ');
  188.        write(y_bwave,t_bwave,diff);
  189.        writeln(alert,c);
  190.     end;
  191. END;     { of if good_date = date }
  192. if last_ticker then
  193. begin
  194.    writeln('\t\t\n\n------------- SUMMARY--------------------');
  195.    writeln('\tTickers Processed             ',INT(tick_total));
  196.    writeln('\tYesterday Binary Wave Average ',y_total/tick_total);
  197.    writeln('\tToday Binary Wave Average     ',t_total/tick_total);
  198.    writeln('\tAverage Change in Binary Wave ',c_total/tick_total);
  199.    writeln('\t',INT(buy_count),' BUY Signals');
  200.    writeln('\t',INT(sell_count),' SELL Signals');
  201. end;
  202.  
  203.