home *** CD-ROM | disk | FTP | other *** search
/ Monster Media 1993 #2 / Image.iso / finance / tas515dm.zip / EXAMPLES.ZIP / FINDVAL.TAS < prev    next >
Text File  |  1991-04-28  |  1KB  |  41 lines

  1. { FINDVAL.TAS
  2.         TAS Script to show how you can find the close price when
  3.         an RSI value in the past was at a certain level.
  4.         If the current RSI is less than or equal to 30, find
  5.         the last time the RSI was less than or equal to 30 and
  6.         print out the price on that day and the price today.
  7.         Requires TAS 3.58 or later.
  8. }
  9. #OUTPUT_FILE 'FINDVAL.LST'
  10. rsi_a : array;
  11. rsi_a = rsi(14);
  12. if rsi_a > 30 RETURN;           { Leave script if RSI > 30}
  13. i = quote_count;                { Set loop variable to # quotes}
  14. was_above_30 = 0;               { Set to 1 when we find RSI > 30}
  15.   Loop through the rsi array going back from today to the past. 
  16.   First we have to find an RSI above 30 before we start checking
  17.   for an RSI below 30. 
  18.   Stop looking if we reach day 14 in the quotes, since the RSI
  19.   will be undefined on that day.
  20. }
  21. :LOOP
  22. if i <= 14 then RETURN;
  23. if rsi_a[i] > 30 then
  24.    was_above_30 = 1;
  25. if was_above_30 = 1 AND rsi_a[i] <= 30 then
  26.    GOTO IFOUNDIT;        
  27. :NEXTDAY
  28.    i = i-1;                   { go back one day }
  29.    GOTO LOOP;
  30. :IFOUNDIT
  31. { Check if we should put out a heading }
  32. if header_done = 0 THEN
  33. BEGIN
  34. WRITELN('           ---Todays----    ---Prior----   Days in      ');
  35. WRITELN('TICKER     Close     RSI    Close    RSI     Past    Date');
  36. header_done = 1;
  37. END;
  38. WRITELN(TICKER,C,rsi_a,C[i],rsi_a[i],'    ',int(quote_count-i),
  39.         '  ',DATESTR(DATES[i]));
  40.