home *** CD-ROM | disk | FTP | other *** search
/ Monster Media 1993 #2 / Image.iso / finance / tas515dm.zip / EXAMPLES.ZIP / BBANDX.TAS < prev    next >
Text File  |  1992-03-02  |  3KB  |  93 lines

  1. { BBAND.TAS - This script computes BOLLINGER BANDS.
  2.   Bollinger bands are lines which are 'n' standard deviations away
  3.   from a 'p' day moving average of the close.
  4.   To change the value of 'n', change 'bband_devs' below. To
  5.   change the value of 'p', change 'bband_period' below.
  6.   NOTE- This script will use the optional GRAPH feature of TAS.
  7.   If it is not registered to run GRAPH's then it will terminate
  8.   on the SECOND graph.
  9.   If you wish to continue viewing graphs, see the REGISTER.DOC
  10.   file included with the TAS system. That file contains the
  11.   pricing and ordering information for the GRAPH feature.
  12. -
  13. -
  14. *Script modified 2/27/92 by Tom Rategan. Graph now tells Close, Change,
  15. High, % Off High, and 30 Day Trading Range. Volume Graph tells Volume,
  16. 50-day Average Volume, % Today vs Average, prior 7 day average, and
  17. 7 day vs 50 day %. The 7 day average does not include today, rather it
  18. averages volume between yesterday and 8 days ago. BBand breakouts are
  19. often accompanied by high volume and so including today's volume may
  20. obscure the 7 day average. The 7 day average tries to show how volume
  21. recently compares with the longer average.
  22. Screen displays most of the same data during scanning.
  23. }
  24. #output_file 'bband.lst' n
  25. if first_ticker then begin
  26. writeln
  27. ('     Name           Close   Change  BO Dir    %OH  %30Rng   Vol     %Vol'
  28. );
  29. writeln
  30. ('     ----           -----   ------  ------    ---  ------   ---     ----'
  31. );
  32. end;
  33. GRAPH_SWITCH = 1; {<--------- SET THIS TO 1 TO SEE GRAPHS}
  34. bband_period = 20;              { number of days in BBAND period }
  35. bband_devs   = 2;               { number of STD DEVIATIONS about close}
  36. bband_top : array;              { top band }
  37. bband_bot : array;              { bottom band }
  38. {
  39.   Top Bollinger Band
  40. }
  41. bband_top = bbandt(20,2);
  42. {
  43.   Bottom Bollinger Band
  44. }
  45. bband_bot = bbandb(20,2);
  46. { Now, the rest is up to you. I have suppied a simple check to see
  47.   if the current close is over the top band or below the bottom band.
  48.   You can use these BBAND arrays to check for the narrowing of the
  49.   bands, tops or bottoms outside the bands, and bouncing off the
  50.   bands.
  51. }
  52. if over(c,bband_top) <= 0 then
  53. begin
  54. gosub dograph;
  55. writeln(fullname,' ',c[0],' ',chg,'  Upward ',int(oh),'% ',int(r30),'% '
  56. ,v,' ',int(v_v50),'%');
  57. end;
  58. if over(bband_bot,c) <= 0 then
  59. begin
  60.   gosub dograph;
  61. writeln(fullname,' ',c[0],' ',chg,'  Dnward ',int(oh),'% ',int(r30),'% '
  62. ,v,' ',int(v_v50),'%');
  63. end;
  64. return;
  65. :dograph
  66. hivalqc : array;
  67. hi30 : array;
  68. lo30 : array;
  69. v50 : array;
  70. qc = (quote_count - 2);
  71. hi30 = hhv(c,30);
  72. lo30 = llv(c,30);
  73. hivalqc = hhv(c,qc);
  74. r30 = (1-(lo30/hi30))*100;
  75. oh = 100-((c/hivalqc)*100);
  76. v50 = mov(v,50,'s');
  77. v7 = ((v[-1]+v[-2]+v[-3]+v[-4]+v[-5]+v[-6]+v[-7])/7)
  78. v_v50 =((v[0]/v50[0])* 100);
  79. v7_v50 = ((v7/v50[0])*100);
  80. chg = c[0] - c[-1];
  81. if graph_switch = 0 then return;
  82. opengraph(2);
  83. sizegraph(4,2);       { size the graphs 2/3, 1/3}
  84. graph(1,''+format(c[0],'$%5.2f')+' is '
  85. +format(oh,'%5.2f%')+' off '+format(hivalqc[0],'$%5.2f')
  86. +' high.   Change= '+format(chg,'$%2.2f')+'   30 day range= '
  87. +format(r30,'%2.2f%'),bband_top,bband_bot,);
  88. graph(v,'Today='+format(v[0],'%5.f')+'    50MA='+format(v50[0],'%5.f')
  89. +'    %Today='+format(v_v50,'%4.f%')+'    Prior 7MA='+format(v7,'%5.f')
  90. +','+format(v7_v50,'%4.f%')+' of',v50,'50MA');
  91. closegraph();
  92. return;
  93.