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

  1.  { DIFFNDX.TAS, Version 1.1
  2.    *
  3.    Script to create graphs based on the "Diffusion Index".  It is
  4.    calculated by taking a ratio of the number of stocks with closing
  5.    prices that are up over 9 months versus all stocks in the
  6.    population.  Diffusion index signals:
  7.    >  90% or more -- Early selling warning, do no more buying and
  8.       start to weed out stocks to build cash.
  9.    >  Decline from over 90% to 50% -- Immediate final sell signal
  10.       from a market top.  Liquidate all holdings immediately.
  11.    >  Under 10% -- Too late to sell; major panic bottom forming.
  12.    *
  13.    All stocks in ticker list should have at least the number of
  14.    quotes specified in the #MAX_QUOTES statement, or they will be
  15.    ignored in all calculations of the Diffusion Index.  I generally
  16.    use my DJ30 (Dow Jones Industrials) ticker list with the script.
  17.    *
  18.    Use the "@" command parameters to change default settings of the
  19.    variables used in this program.  For example:
  20.        TAS pgmname tickerlist @variable=xxx
  21.    *
  22.    Note the statement "#INCLUDE SCANDATE.SUB".  In order to run this
  23.    program, a file named SCANDATE.SUB must exist.  The default file
  24.    just contains a comment ("Subroutine for possible #SCAN_DATE").
  25.    This default does NOT affect the running of the program.  But, it
  26.    will allow you to run the program from a BATch file several times
  27.    using different #SCANDATE parameters.  For example:
  28.        REM ********************************************************
  29.        REM * pgmname.BAT
  30.        REM * Run pgmname.TAS for different days
  31.        REM ********************************************************
  32.        copy   scandate.sub scandate.bak
  33.        erase  pgmname.lst
  34.        echo   #SCAN_DATE 910923   >scandate.sub
  35.        tas    pgmname  tickerlist @variable=xxx
  36.        echo   #SCAN_DATE 910930   >scandate.sub
  37.        tas    pgmname  tickerlist @variable=xxx
  38.        REM ********************************************************
  39.        REM * Reset the SCANDATE.SUB file so it won't do anything
  40.        REM ********************************************************
  41.        copy   scandate.bak scandate.sub
  42.        erase  scandate.bak
  43.    *
  44.    Created 11/25/91 by Martin Moore (on request by Mitchell Herman)
  45.    Changed 11/28/91 (1.1) / Format changes by Randy Harmelink
  46.                           / Add documentation and INDEX graph
  47.    }
  48.  #INCLUDE SCANDATE.SUB           { Possible #SCAN_DATE parameter }
  49.  #MAX_QUOTES 500
  50.  #INDEX 'sp-500'
  51.  {**************************************************************}
  52.  { Create defaults for parameters of technical studies          }
  53.  { ------------------------------------------------------------ }
  54.  { "LookBack"  indicates the number of days to use for looking  }
  55.  {             back for computation of the Diffusion Index.     }
  56.  {             The default is 9 months (i.e. 9 * 22).           }
  57.  {**************************************************************}
  58.  if QuotesUse = 0 then QuotesUse := Quote_Count;
  59.  if LookBack  = 0 then LookBack  := 9 * 22;
  60.  {**************************************************************}
  61.  { Define arrays used in program                                }
  62.  {**************************************************************}
  63.  DiffUp    : Array; { Up issues }
  64.  DiffTot   : Array; { Total issues }
  65.  {**************************************************************}
  66.  { Examine individual stocks to see if they are up over period  }
  67.  {**************************************************************}
  68.  if Quote_Count >= QuotesUse then
  69.     for i = LookBack + 1; i <= Quote_Count ; i = i + 1;
  70.         if Close[i] > Close[i-LookBack] then begin
  71.            DiffUp[i]  := DiffUp[i]  + 1;
  72.            DiffTot[i] := DiffTot[i] + 1;
  73.            end;
  74.         else
  75.            DiffTot[i] := DiffTot[i] + 1;
  76.  {**************************************************************}
  77.  { Display results when all stocks have been examined           }
  78.  {**************************************************************}
  79.  if Last_Ticker then begin
  80.     DiffUp := MulBy(Div(DiffUp,DiffTot),100);
  81.     opengraph(2,-QuotesUse+LookBack,0);
  82.     graph(DiffUp,'Diffusion Index: '+format(diffUp[0],'%5.2f%%'));
  83.     graph(Index,'DJIA closing prices');
  84.     CloseGraph();
  85.     end;
  86.