home *** CD-ROM | disk | FTP | other *** search
/ Monster Media 1993 #2 / Image.iso / finance / tas515dm.zip / EXAMPLES.ZIP / STUD1PT.TAS < prev    next >
Text File  |  1991-04-13  |  6KB  |  181 lines

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