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

  1. {SLOPE ver 2.0}
  2. {This script REQUIRES THE GRAPHICS FUNCTION
  3. }
  4. {This script is based on Forecasting Tommorows Trading Day -
  5.  Technical Analysis of Stocks and Commodities - May Issue.
  6. }
  7. {Rules  :
  8.          1. Use the forecast only if correlation is above .1, the higher
  9.             the reading the greater the confidence.
  10.          2. A trend change is imminent when the correlation index falls
  11.             below .1.
  12.          3. A trend is in place when the correlation index is above .6, you
  13.             can wait for this to avoid being whipsawed.
  14.          4. An early warning of a trend change is given when the frequency
  15.             oscillator crosses the 0 line. Prepare to tighten positions.
  16.          5. A change in trend is confirmed by a change in slope. Open
  17.             positions in the direction of the trend.
  18.          6. The trend will normally change in the direction of f%.
  19.          7. Always be prepared for a market move against the forecast,
  20.             USE STOPS!
  21. }
  22. {Written by : Steve Hedlund 818-368-2897
  23. }
  24. {=====================================================================}
  25. {SET UP STARTING VARIABLES}
  26. {=====================================================================}
  27. #max_quotes 50
  28. QS=50;           {SET SAME AS MAX QUOTES}
  29. LN :=5;          {REGRESSION PERIOD}
  30. {=====================================================================}
  31. {SET UP ARRAYS AND VARIABLES}
  32. {=====================================================================}
  33. hx : array;       {Linreg array}
  34. hx1 : array;      {Forecast array}
  35. hx3 : array;      {Oscillator }
  36. hX4 : ARRAY;      {Move Forecast ahead 1 day}
  37. hX6 : ARRAY;      {Correlation array}
  38. hcon: array;      {Stores the Constant of the linreg}
  39. hxx : array;      {Slope array}
  40. cx : array;       {Linreg array}
  41. cx1 : array;      {Forecast array}
  42. cx3 : array;      {Oscillator }
  43. cX4 : ARRAY;      {Move Forecast ahead 1 day}
  44. cX6 : ARRAY;      {Correlation array}
  45. ccon: array;      {Stores the Constant of the linreg}
  46. cxx : array;      {Slope array}
  47. lx : array;       {Linreg array}
  48. lx1 : array;      {Forecast array}
  49. lx3 : array;      {Oscillator }
  50. lX4 : ARRAY;      {Move Forecast ahead 1 day}
  51. lX6 : ARRAY;      {Correlation array}
  52. lcon: array;      {Stores the Constant of the linreg}
  53. lxx : array;      {Slope array}
  54. ST=0;             {first day for linreg - changed by loop}
  55. lt=ln             {last day for linreg - changed by loop}
  56. gt:=(qs-ln-1)*(-1); {skip the days at the start of linreg}
  57. {=====================================================================}
  58. {CHECKS}
  59. {=====================================================================}
  60. if quote_count<qs then return;
  61. {=====================================================================}
  62. {LINEAR REGRESSION - APROXIMATE LINE
  63. {=====================================================================}
  64. for i=lt;i<=qs;i=i+1;
  65. BEGIN
  66. cX[I] := LINREG(c,ST,LT);
  67. ccon[i] := p[(lt-(ln-1))]              {MARTIN - THIS IS WHAT I NEEDED TO DO
  68. }
  69. cxx[i] := SLOPE(LINREG(c,ST,LT));    {TO GET CONSTANT FROM LINREG}
  70. cx6[i] := CORRCOEF()/100;
  71. cx1[i] := ccon[i]+(cxx[I]*(LN+1));   {compute forecast}
  72. hX[I] := LINREG(h,ST,LT);
  73. Hcon[i] := p[(lt-(ln-1))];       {Get Constant from Linreg}
  74. hxx[i] := SLOPE(LINREG(h,ST,LT));
  75. hx6[i] := CORRCOEF()/100;
  76. hX1[i] := hcon[i]+(hXX[I]*(LN+1));   {compute forecast}
  77. lX[I] := LINREG(l,ST,LT);
  78. lcon[i] := p[(lt-(ln-1))]
  79. lxx[i] := SLOPE(LINREG(l,ST,LT));
  80. lx6[i] := CORRCOEF()/100;
  81. lX1[i] := lcon[i]+(lXX[I]*(LN+1));   {compute forecast}
  82. ST=ST+1;
  83. LT=LT+1;
  84. END;
  85. {=====================================================================
  86.  CALCULATE OSCILLATORS
  87. ======================================================================}
  88. for i=1;i<=(qs);i=i+1;
  89. begin
  90. cx3[i] := ((c[i]-cx1[(i-1)])/c[i])*100;
  91. cx4[i] := cx1[(i-1)];
  92. hx3[i] := ((h[i]-hx1[(i-1)])/h[i])*100;
  93. hx4[i] := hx1[(i-1)];
  94. lx3[i] := ((l[i]-lx1[(i-1)])/l[i])*100;
  95. lx4[i] := lx1[(i-1)];
  96. end;
  97. {=====================================================================}
  98. {GRAPHS}
  99. {=====================================================================}
  100. opengraph(4,gt);
  101. sizegraph(2,1,1,1);
  102. graph(1,cx4,format(cx1[0],'Tomorrows Close %5.2f'),hx4,format(hx1[0],
  103. 'Tomorrows Hi %5.2f'),lx1,format(lx1[0],'Tomorrows Low %5.2f'));
  104. GRAPH(cX3,'FREQUENCY OSCILLATOR - Close',hx3,'Hi',Lx3,'Low');
  105. GRAPH(cX6,'CORRELATION INDEX - Close',hx6,'Hi',lx6,'Low');
  106. GRAPH(cXx,'SLOPE - Close',hxx,'Hi',lxx,'Low');
  107. closegraph();
  108.