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

  1. {
  2. A script written to simply graph all stocks in the ticker list. Good for
  3. checking up on your current holds, or those which you are interested in
  4. watching closely. It should be noted that the volume 5MA and 10MA
  5. calculations do not include today, rather they end yesterday. They are
  6. intended to show how volume has behaved in the one-week and two-week
  7. periods immediately prior to today.
  8. Written 3/28/92 by Tom Rategan.   Prodigy PMGV10A.
  9. *
  10. Modified 08/03/92 to include optional up/down (U/D) volume ratio graph.
  11. The U/D graph can be turned on or off by the user with the "switch" in
  12. the first line of the script.
  13. 40 day ratio divides the total volume on days when the stock's average
  14. price weighted toward the close ((H+L+C)/3) was higher than the previous
  15. day, by the total volume on days the average price was lower. Attemps to
  16. show whether a stock has been seeing accumulation or distribution.
  17. The U/D graph is computed a unique way in this script. It attempts to show
  18. accumulation and distribution effectively, while filtering out the
  19. exagerations and distortions which U/D ratios can be subject to due
  20. to periods of extreme volume.
  21. 40 days are used in computing the ratio.  The "average price
  22. weighted toward the close" (  (H+L+C)/3  ) is used to determine whether
  23. the price was up or down from day to day. If a stock trades between
  24. 150% and 200% of its 40 day MA, the volume figure added to the up or
  25. down side array is 150% of the 40 day MA. If more than 200% of the 40 day
  26. MA is traded, then only 200% of the average volume is added to the
  27. up side or the down side. In other words, there is a ceiling of 200%
  28. of normal volume which can be used in the U/D calculation. If a stock
  29. trades 300%, 700%, 1000% or more of its 40 day average volume, then
  30. only 200% of the 40MA on the day the volume took place is added.
  31. The legend on top of the U/D graph shows the current U/D, the change
  32. from yesterday, the percent of time in the past 40 days the ratio was
  33. greater than 1, and how many days ago the last cross of the 1 line
  34. took place. The percent above 1 figure is helpful if the ratio has been
  35. very close to the 1 line for awhile and it's difficult to tell which
  36. side it has been on more of the time.
  37. Also given in the U/D graph legend is the standard 50 U/D. This is the
  38. simple ratio using only the close in determining whether price was up or
  39. down, and with no filtering of extreme volume. This is the method which
  40. Investor's Business Daily uses in its graphs, so I included it for
  41. comparison.
  42. The script will now graph any stock with at least 5 days of data. 50MA
  43. and 200MA lines as well as the U/D graph are shown depending on whether
  44. there is enough data. If there are fewer than 50 days of data, the volume
  45. graph will make a moving average of the total number of days available
  46. minus two.
  47. }
  48. UD_GRAPH_SWITCH = 1;  { <<<< "0"= no U/D graph, "1"= U/D graph shown. }
  49. if quote_count < 5 then return;
  50. #max_quotes 305
  51. less51 = 0;
  52. less201 = 0;
  53. if quote_count < 51 then less51 = 1
  54. if quote_count < 51 then ud_graph_switch = 0;
  55. if quote_count < 201 then less201 = 1;
  56. qc = (quote_count-2);
  57. hiqc : array;
  58. hiqc = hhv(c,qc);
  59. oh = (1-(c[0]/hiqc[0]))*100;
  60. chg = c[0]-c[-1];
  61. if less51 = 1 then goto vol;
  62. hi30 : array;
  63. lo30 : array;
  64. hi30 = hhv(c,30);
  65. lo30 = llv(c,30);
  66. r30 = (1-(lo30/hi30))*100;
  67. p50 : array;
  68. p50 = mov(c,50,'s');
  69. if c[0] >= p50[0] then off50 = (1-(p50[0]/c[0]))*100
  70. else off50 = (1-(c[0]/p50[0]))*100;
  71. if less201 = 1 then goto vol;
  72. p200 : array;
  73. p200 = mov(c,200,'s');
  74. if c[0] >= p200[0] then off200 = (1-(p200[0]/c[0]))*100
  75. else off200 = (1-(c[0]/p200[0]))*100
  76. :vol
  77. if less51 = 1 then goto shortvol_ma;
  78. v50 : array;
  79. v50 = mov(v,50,'s');
  80. vv50 = (v[0]/v50[-1])*100;
  81. v5 = (v[-1]+v[-2]+v[-3]+v[-4]+v[-5])/5;
  82. v5v50 = (v5/v50[-1])*100;
  83. v10 = (v[-1]+v[-2]+v[-3]+v[-4]+v[-5]+v[-6]+v[-7]+v[-8]+v[-9]+v[-10])/10;
  84. v10v50 = (v10/v50[-1])*100;
  85. goto ud_check;
  86. :shortvol_ma
  87. vx : array;
  88. vx = mov(v,qc,'s');
  89. vvx = (v[0]/vx[-1])*100;
  90. :ud_check
  91. if ud_graph_switch = 0 then goto graphit;
  92. v40 : array;
  93. v40 = mov(v,40,'s');
  94. ud2:array;
  95. up2:array;
  96. dn2:array;
  97. maup2:array;
  98. madn2:array;
  99. vo : array;
  100. vo = v;
  101. up2[1]:=0; dn2[1]:=0;
  102. for j := 2; j<= quote_count; j:=j+1;
  103. begin
  104. if j < 40 then v40[j] = v40[1];
  105. if vo[j] > (v40[j]*1.5) and vo[j] < (v40[j]*2) then vo[j] = (v40[j]*1.5);
  106. if vo[j] >= (v40[j]*2) then vo[j] = (v40[j]*2);
  107. if (h[j]+l[j]+c[j])/3 > (h[j-1]+l[j-1]+c[j-1])/3 then up2[j]:=vo[j] else
  108. up2[j]:=0;
  109. if (h[j]+l[j]+c[j])/3 < (h[j-1]+l[j-1]+c[j-1])/3 then dn2[j]:=vo[j] else
  110. dn2[j]:=0
  111. end;
  112. maup2:=Mov(up2,40,'s');
  113. madn2:=Mov(dn2,40,'s');
  114. ud2:=div(maup2,madn2);
  115. ud_chg= ud2[0] - ud2[-1];
  116. da= -40;
  117. np = 0;
  118. :check_perc_one
  119. da = da + 1;
  120. if da = 1 then goto perc_one;
  121. if ud2[da]>=1 then np = np + 1;
  122. goto check_perc_one;
  123. :perc_one
  124. p_one = (np/40)*100;
  125. x_ago = 1;
  126. :check_cross
  127. x_ago = x_ago - 1;
  128. if ud2[x_ago] >1 and ud2[x_ago-1] <1 then goto ud50;
  129. if ud2[x_ago]<1 and ud2[x_ago-1] >1 then goto ud50 else goto check_cross;
  130. :ud50
  131. if x_ago <> 0 then x_ago = -x_ago;
  132. av = 0;
  133. dv = 0;
  134. d = -51;
  135. :loop
  136. gosub count;
  137. if d = 0 then goto figure;
  138. if c[d] < c[d+1] then av = av + v[d+1];
  139. if c[d] > c[d+1] then dv = dv + v[d+1];
  140. goto loop;
  141. :count
  142. d = d + 1;
  143. return;
  144. :figure
  145. ud = av/dv;
  146. :graphit
  147. if ud_graph_switch = 1 then goto graph_ud;
  148. opengraph(2,-255,0);
  149. sizegraph(4,2);
  150. goto graph_wo_ud;
  151. :graph_ud
  152. opengraph(3,-255,0);
  153. sizegraph(3,1,1);
  154. :graph_wo_ud
  155. if less51 = 1 then goto graph_less51;
  156. if less51 = 0 and less201 = 1 then goto graph_51_201;
  157. graph(1,' '+format(c[0],'$%3.2f')+' is '+format(oh,'%2.1f%')+
  158. ' off '+format(hiqc[0],'$%3.2f')+' high.  Change= '+format(chg,'$%2.2f')
  159. +'  30 Range= '+format(r30,'%3.1f%'),p50,format(off50,'%2.f%')+
  160. ' off 50MA',p200,format(off200,'%2.f%')+' off 200MA');
  161. goto graphvol;
  162. :graph_51_201
  163. graph(1,' '+format(c[0],'$%3.2f')+' is '+format(oh,'%2.1f%')+
  164. ' off '+format(hiqc[0],'$%3.2f')+' high.  Change= '+format(chg,'$%2.2f')
  165. +'  30 Range= '+format(r30,'%3.1f%'),p50,format(off50,'%2.f%')+
  166. ' off 50MA');goto graphvol;
  167. :graph_less51
  168. graph(1,' '+format(c[0],'$%3.2f')+' is '+format(oh,'%2.1f%')+
  169. ' off '+format(hiqc[0],'$%3.2f')+' high.  Change= '+format(chg,'$%2.2f'));
  170. :graphvol
  171. if less51 = 1 then goto vol_less51;
  172. graph(v,'Today='+format(v[0],'%5.f')+'     50MA='+format(v50[-1],'%5.f')
  173. +'    %Today='+format(vv50,'%4.f%')
  174. +'    5MA= '+format(v5v50,'%3.f%')
  175. +' of 50MA    10MA= '+format(v10v50,'%3.f%')+' of',v50,'50MA');
  176. goto udgraph;
  177. :vol_less51
  178. graph(v,'Today='+format(v[0],'%5.f')+'      '+format(qc,'%2.f')+' Day MA= '
  179. +format(vx[-1],'%5.f')+'     %Today='+format(vvx,'%4.f%'),vx,'      '+
  180. format(qc,'%2.f')+' Day MA');
  181. :udgraph
  182. if ud_graph_switch = 0 then goto close;
  183. graph(ud2,'40 U/D= '+format(ud2[0],'%1.2f')+'   Change= '
  184. +format(ud_chg,'%0.2f')+'   Above ONE (40 Days)= '+format(p_one,'%2.f%')
  185. +'   Last Cross '+format(x_ago,'%1.f')+' Days Ago.   50 U/D= '
  186. +format(ud,'%1.2f'));
  187. drawline(7,0,1,0,1);
  188. :close
  189. closegraph();
  190. return;
  191.