home *** CD-ROM | disk | FTP | other *** search
/ Monster Media 1993 #2 / Image.iso / finance / tas515dm.zip / EXAMPLES.ZIP / CYCLE.TAS < prev    next >
Text File  |  1991-09-19  |  2KB  |  50 lines

  1. {     This is a script that will look at the last five peaks of a 5%
  2.       filtered wave of a stock and average those peaks to find the
  3.       common cycle of peaks.  It then finds the half cycle and uses that
  4.       number to determine a stochastic and top Bollinger band.
  5.       This same technique is used to find the cycles for troughs.
  6.       The values of the peak and trough are usually close, but there is
  7.       enough difference to change the buy and sell points.  Take a
  8.       good look at the way the Bollinger bands respond to this and where
  9.       the stochastic is when the price leaves the band.
  10.       written by Jerry Green, Sept. 91, TAS404 version.}
  11. #max_quotes 200
  12. ziggy : array;                   {define an array as ziggy}
  13. ziggy = ZIG(c,5,'%');            {take a five percent ZIG ZAG}
  14. peak_5 = (0-peak(ziggy,5));      {find the peak 5 waves ago}
  15. peak_4 = (0-peak(ziggy,4));      {the 0- is to convert to a + number}
  16. peak_3 = (0-peak(ziggy,3));
  17. peak_2 = (0-peak(ziggy,2));
  18. peak_1 = (0-peak(ziggy,1));
  19. { Find out how long the peak took by subtracting the next one. }
  20. peak_5 = peak_5 - peak_4;
  21. peak_4 = peak_4 - peak_3;
  22. peak_3 = peak_3 - peak_2;
  23. peak_2 = peak_2 - peak_1;
  24. trof_5 = (0-trough(ziggy,5));
  25. trof_4 = (0-trough(ziggy,4));
  26. trof_3 = (0-trough(ziggy,3));
  27. trof_2 = (0-trough(ziggy,2));
  28. trof_1 = (0-trough(ziggy,1));
  29. { Find out the value of each trough. }
  30. trof_5 = trof_5 - trof_4;
  31. trof_4 = trof_4 - trof_3;
  32. trof_3 = trof_3 - trof_2;
  33. trof_2 = trof_2 - trof_1;
  34. peak_avg = peak_5 + peak_4 + peak_3 + peak_2 + peak_1;   {add the peaks}
  35. peak_avg = peak_avg/5;                                   {average them}
  36. trof_avg = trof_5 + trof_4 + trof_3 + trof_2 + trof_1;   {add the trofs}
  37. trof_avg = trof_avg/5;                                   {average
  38. them }peak_cycle = peak_avg/2;             {find the half cycle}
  39. trof_cycle = trof_avg/2;             {find the half cycle}
  40. OPENGRAPH(3,-100,0);
  41. graph(1,'PRICE with cycle BB',BBANDT(peak_cycle,2),'TopBB',
  42. BBANDB(trof_cycle,2),'BotBB');
  43. graph(stoch(peak_cycle,3),'STOCH PEAK HALF CYCLE');
  44. drawline(10,0,80,0,80);
  45. drawline(10,0,20,0,20);
  46. graph(stoch(trof_cycle,3),'STOCH TROF HALF CYCLE');
  47. drawline(10,0,80,0,80);
  48. drawline(10,0,20,0,20);
  49. CLOSEGRAPH();
  50.