home *** CD-ROM | disk | FTP | other *** search
/ Monster Media 1993 #2 / Image.iso / finance / tas515dm.zip / EXAMPLES.ZIP / TITANIC.TAS < prev    next >
Text File  |  1991-08-21  |  7KB  |  209 lines

  1.  
  2. { TITANIC.TAS
  3.    This script follows the trading strategy described in the
  4.    Equis "Monitor" (Vol. 6, No. 2, July 1991) article titled
  5.    "How to Avoid Sinking with the Titanic" by William Ohama.      
  6.    -----------------------------------------------------
  7.    To run this, you should have a ticker file containing
  8.    only the following tickers
  9.    DJ-30        Dow 30 Industrials
  10.    -----------------------------------------------------
  11.    This script assumes that the following ticker names are
  12.    used for the indices shown at right.
  13.    NYNH -       NYSE New High Issues
  14.    NYNL -       NYSE New Low  Issues
  15.    NYAD -       NYSE ADV Issues
  16.    NYDE -       NYSE DEC Issues
  17. }
  18. {#SCAN_DATE 790102 851231   if using TAS 4.04, you can do this}
  19. #OUTPUT_FILE 'TITANIC.LST'
  20. #PROFIT_TEST  BOTH    5000   N
  21. #PROFIT_COMM  NOCOMM ONESHARE   0 - TODAYS CLOSE  
  22. #PROFIT_OUTPUT  DETAIL
  23. GRAPH_IT = 0;           { Set to 1 to see graphs}
  24. NYADname = 'NYAD';      { Change to your NYSE Adv Issues ticker}
  25. NYDEname = 'NYDE';      { Change to your NYSE Dec Issues ticker}
  26. NYNHname = 'NYNH';      { Change to your NYSE New Highs ticker}
  27. NYNLname = 'NYNL';      { Change to your NYSE New Lows  ticker}
  28. NYAD : ARRAY;           { advancing issues}
  29. NYDE : ARRAY;           { declining issues}
  30. NYNH : ARRAY;           { New High  issues}
  31. NYNL : ARRAY;           { New Low   issues}
  32. { Computed values follow here }
  33. NHNL : ARRAY;           { New Highs - New Lows}
  34. DJHIGH : ARRAY;         { 52 Week DJIA High}
  35. COUNT_ARRAY : ARRAY;    { Array to use to count > 1000 issue days}
  36. buy_rule_1  : number;   { 10% drop in the DJIA from 52 week high}
  37. sell_rule_1 : number;   { DJIA makes a 52 week high}
  38. buy_signal  : number;   { Set to 1, 2, or 3 for rules which hit}
  39. sell_signal : number;   { Set to 1 or 2 for sell rules}
  40. sell_price  : number;   { used for Stop/Reversal }
  41. sell_date   : number;   { used to hold date of SELL 52 week high}
  42. over_1000_days : number;   { number of days of >1000 AD or DE}
  43. day_of_52_week_high : number;  { saves day of 52 week high}        
  44.  
  45. PLOT BEGIN
  46. IF CHARTPRO_FLAG = 0 THEN
  47. BEGIN
  48. NYAD = LOAD(NYADname,'C');
  49. NYDE = LOAD(NYDEname,'C');
  50. NYNH = LOAD(NYNHname,'C');
  51. NYNL = LOAD(NYNLname,'C');
  52. END
  53. ELSE
  54. BEGIN
  55. if ticker = NYADname then   
  56.    NYAD = C;                    { #issues in the CLOSE field}
  57. if ticker = NYDEname then
  58.    NYDE = C;                    { #issues in the CLOSE field}
  59. if ticker = NYNHname then
  60.    NYNH = C;                    { #issues in the CLOSE field}
  61. if ticker = NYNLname then
  62.    NYNL = C;                    { #issues in the CLOSE field}
  63. END;
  64. if last_ticker = 1 then
  65.    BEGIN
  66.    NHNL = SUB(NYNH,NYNL);
  67.    DJHIGH = HHV(H,52*5);     { 52 Week highs}
  68.    {dump_array(H,L,C,nyad,nyde,nynh,nynl,djhigh);}
  69.    END;
  70. END;
  71. if last_ticker = 0 then return;  
  72. {----------COMPUTATION HERE --------------}
  73. { Buy signals are done here---------------}
  74. buy_signal = 0;     { indicate no buy signal}
  75. If L < DJHIGH * .9 then
  76.    buy_rule_1 = 1;   
  77. if buy_rule_1 then 
  78.    { 
  79.      NYSE Advancing > 1000 for two consecutive days and one of 
  80.      those days shows Advance/Decline ratio > 4.00
  81.    }
  82.    if NYAD[-1] > 1000 and NYAD > 1000 and 
  83.       ((NYAD[-1]/NYDE[-1] > 4) OR (NYAD/NYDE > 4)) then
  84.       buy_signal = 1
  85.    else
  86.    { the Advance/Decline ration > 9.00 or < 0.11}
  87.    if NYAD/NYDE > 9.00 or NYAD/NYDE < 0.11 then
  88.       buy_signal = 2
  89.    else
  90.    begin
  91.       COUNT_ARRAY = NYAD;  { copy NYAD to COUNT_ARRAY}
  92.       gosub COUNT_1000_DAYS;
  93.       if over_1000_days >= 4 then
  94.          buy_signal = 3;
  95.    end;
  96. if buy_signal <> 0 then 
  97. begin
  98.    if PT_BUY() <> 0 then 
  99.    begin
  100.       write('^BUY-');
  101.       if buy_signal = 1 then
  102.          writeln('4 of 7 days after ',
  103.             DATESTR(DATES[day_of_52_week_high]),
  104.             ' NYAD > 1000 for 2 consecutive days');
  105.       if buy_signal = 2 then
  106.          writeln('After ',
  107.             DATESTR(DATES[day_of_52_week_high]),
  108.             ' AD/DE Ratio > 9 or less than 0.11');
  109.       if buy_signal = 3 then
  110.          writeln('After ',
  111.             DATESTR(DATES[day_of_52_week_high]),
  112.             ' 4 of 7 days where NYAD > 1000');
  113.       buy_signal = 0;
  114.       buy_rule_1 = 0;
  115.       sell_price = 0;
  116.       return;   { skip sell signal since we made a buy}
  117.    end;
  118. end;
  119.  
  120. { Sell signals are done here---------------}
  121. sell_signal = 0;    { indicate no signal}
  122. if H = DJHIGH then   { if today's DJ30 is the 52 week high}
  123. begin
  124.    day_of_52_week_high = quote_count;  { save current index}
  125.    sell_rule_1 = 1;  { first condition met}
  126.    buy_rule_1 = 0;   { remove buy alert and wait for drop}
  127. end;
  128. if sell_price <> 0 then
  129. begin
  130.     if H > (sell_price * 1.02) then
  131.     begin
  132.         PT_BUY();
  133.         writeln('^BUY-Sell Signal reversal to Buy Signal',h,' > 1.02 *',
  134.         sell_price,' on ',datestr(sell_date));
  135.         sell_rule_1 = 0;
  136.         sell_price = 0;
  137.         return; { skip sell signal since we made a buy}
  138.     end;
  139. end;
  140. if sell_rule_1 then
  141. begin
  142.    gosub CHECK_NL_GT_NH;   
  143.    if new_lows_exceeded_new_highs then 
  144.    begin
  145.        { NYSE Declining > 1000 for two consecutive days and one of those
  146.         days shows Advance/Decline ratio < 0.25}
  147.       if NYDE[-1] > 1000 and NYDE > 1000 and 
  148.          ((NYAD[-1]/NYDE[-1] < 0.25) OR (NYAD/NYDE < 0.25)) then
  149.          sell_signal = 1
  150.       { OR 4 out of 7 day period where the NYSE Declining Issues > 1000}
  151.       COUNT_ARRAY = NYDE;  { copy NYDE to COUNT_ARRAY}
  152.       gosub COUNT_1000_DAYS;    { count the days > 1000}
  153.       if over_1000_days >= 4 then
  154.          sell_signal = 2;
  155. end;
  156. if sell_signal <> 0 then
  157. begin
  158.    if PT_SELL() <> 0 then 
  159.    begin
  160.       sell_price = DJHIGH[day_of_52_week_high];   { Save high DJIA here}
  161.       sell_date = dates[day_of_52_week_high]; { save sell date}
  162.       write('^SELL-');
  163.       if sell_signal = 1 then
  164.          writeln('7 days about ',
  165.             DATESTR(DATES[day_of_52_week_high]),
  166.             ' NL > NH & NYDE > 1000 for 2 days with AD/DE<.25');
  167.       if sell_signal = 2 then
  168.          writeln('4 of 7 days after ',
  169.             DATESTR(DATES[day_of_52_week_high]),
  170.             ' where NYDE > 1000');
  171.       sell_signal = 0;
  172.       sell_rule_1 = 0;
  173.    end;
  174. end;
  175. return;
  176.  
  177. :COUNT_1000_DAYS
  178. { Subroutine to count the number of days in the
  179.   last 7 where NYSE Advancing Issues > 1000 }
  180. over_1000_days = 0;
  181. if COUNT_ARRAY[-6] > 1000 then
  182.    over_1000_days = over_1000_days+1;
  183. if COUNT_ARRAY[-5] > 1000 then
  184.    over_1000_days = over_1000_days+1;
  185. if COUNT_ARRAY[-4] > 1000 then
  186.    over_1000_days = over_1000_days+1;
  187. if COUNT_ARRAY[-3] > 1000 then
  188.    over_1000_days = over_1000_days+1;
  189. if COUNT_ARRAY[-2] > 1000 then
  190.    over_1000_days = over_1000_days+1;
  191. if COUNT_ARRAY[-1] > 1000 then
  192.    over_1000_days = over_1000_days+1;
  193. if COUNT_ARRAY[0] > 1000 then
  194.    over_1000_days = over_1000_days+1;
  195. return;
  196.  
  197. :CHECK_NL_GT_NH
  198. day_index = day_of_52_week_high - 7;
  199. new_lows_exceeded_new_highs = 0;
  200. :check_nl_gt_nh1
  201. if day_index > quote_count then return; 
  202. if day_index > (day_of_52_week_high+7) then return; 
  203. if NYNL[day_index] > NYNH[day_index] then
  204. begin
  205.    new_lows_exceeded_new_highs = new_lows_exceeded_new_highs + 1;
  206. end;
  207. day_index = day_index + 1; 
  208. goto check_nl_gt_nh1;   { go check next day}
  209.