home *** CD-ROM | disk | FTP | other *** search
/ Monster Media 1993 #2 / Image.iso / finance / tas515dm.zip / EXAMPLES.ZIP / AAMOSC.TAS < prev    next >
Text File  |  1992-08-13  |  4KB  |  84 lines

  1. { ******** MOSC.TAS  7/31/92   BY  DENNIS MEYERS ******************}
  2.    {this script computes the McClennan oscillator and then does a
  3.     profit test against the s&p500. The pgm then draws the buy and
  4.     sell points as vertical lines in the ticker graph    }
  5.      { BUY criteria..buy when mosc > +zone
  6.       SELL criteria.. sell when mosc < -zone
  7.       position the same in -zone to + zone }
  8. {********************* IMPORTANT POINTS ***********************}
  9. { a. This pgm could have been (and was) written & tested in MSP3.0
  10.      in 1/10th the time.  The main purpose of my pgm is to serve as 
  11.      model and skeleton for future more complicated profit testing
  12.      pgms that can't be done using MSP3.0}
  13. { 1. This pgm uses the McClellen Osc as a driver to make buy and
  14.      sell decisions on the S&P500.  Any Security could be substituted
  15.      as a ticker to buy and sell.}
  16. { 2. The indicator, in this case the NYSE adv and decl have to
  17.      loaded separately through the LOAD statement. CARE MUST BE
  18.      TAKEN to make sure the load data and the ticker data start
  19.      from the same date. This can be done through a scan_date statement
  20.      as below where YOU KNOW each file has those dates or through
  21.      a #MAX_QUOTES statement where YOU KNOW each file has those SAME
  22.      number of quotes.  }
  23. { 3. I get my data from Dial Data. they put the ADV,DEC,UNC,AV,DV
  24.      in the OHLCV fields of the ticker symbol *NADV. Other vendors
  25.      breakup that data into 5 different ticker symbols.  So in order
  26.      for you to get this program to work you must use Dial Data's
  27.      *NADV or redefine the tickers in the LOAD statments below}
  28. { 4. This pgm runs a profit test for both short and long positions
  29.       using all cash, no commisions, and buying and selling on the close.
  30.       ***NOTE all array declarations MUST COME BEFORE PLOT BEGIN
  31.       statement.}
  32. { 5. This pgm MUST HAVE sub B_S_LINE.TAS in the same directory.
  33.      #include B_S_line.TAS at the bottom appends sub to this pgm.
  34.      B_S_LINE.TAS is the sub that draws (almost)vertical lines
  35.      at the buy and sell points of profit test.}
  36. { 6. The Mosc does not seem to give very timely signals and has a lot
  37.      of whipsaws... using buy and sell on zone crossings...}
  38. #profit_test both 10000
  39. #profit_comm nocomm allcash 0 - todays close
  40. #profit_output detail
  41. #MAX_QUOTES 2000
  42. #scan_date 911001 0     {need this because *nadv and *spx (ticker input)}
  43.                         { are different sizes  *nadv=797 data *spx=1411}
  44.                         {TAS lines up arrays from start date of ticker}
  45.                         {and pads 0's on the end of load data if load  }
  46.                         {data is not a long as tickers data.. TAS will not}
  47.                         {line up dates..that is left to programmer}
  48. #output_file mosc.lst
  49. adv : array;
  50. dec : array;
  51. addiff: array;
  52. mosc : array;
  53. pos : array;
  54. plot begin        {********** PLOT BEGIN **************************}
  55. qe=quote_count;
  56. adv=load('*NADV','O');
  57. dec=load('*NADV','H');
  58. addiff=sub(adv,dec);
  59. mosc=sub(mov(addiff,19,'e'),mov(addiff,39,'e'));
  60. zone=15;
  61. for i=2; i<=qe; i=i+1; begin
  62.   pos[i]=pos[i-1]; {pos remains the same when in dead zone}
  63.   if mosc[i]>zone  pos[i]=1;
  64.   if mosc[i]<-zone pos[i]=-1;
  65.   writeln(int(i),dates[i],c[i],mosc[i],int(pos[i]));
  66. end; {buy sell for loop}
  67. end;                     {******** PLOT END *************}
  68.  BUY WHEN pos=1 and pos[-1]<=0;
  69.  SELL WHEN pos=-1 and pos[-1]>=0;
  70. if end_phase and last_ticker then begin
  71. graph_it=1;
  72. if graph_it=0 return;
  73. lsw=1;
  74. OPENGRAPH(3);
  75. sizegraph(3,2,1);
  76. GRAPH(c,'s&p500');
  77. gosub b_s_line;  {***call the buy sell vertical line generator}
  78. GRAPH(mosc,'McClellan Oscillator');
  79. graph(pos,'Position buy=1 sell=-1');
  80. CLOSEGRAPH();
  81. end; {end_phase=1 if}
  82. return;
  83. #include B_S_LINE.TAS
  84.