home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Monster Media 1993 #2
/
Image.iso
/
finance
/
tas515dm.zip
/
EXAMPLES.ZIP
/
LINPR2.TAS
< prev
next >
Wrap
Text File
|
1993-01-19
|
4KB
|
116 lines
{=====================================================================}
{DESCRIPTION }
{=====================================================================}
{LINPR2.TAS
WRITTEN BY STEVE HEDLUND 818-368-2897
This is a a script I use for testing Linear Progressions using
2 seperate progressions and different moving averages on each.
It has profit testing built into it so you can optimize for each
equity or index.
Signals are given when one moving average crosses the other.
What I do is shift the averages back one day for timely signals and
project what the equity or index must do to create a signal, then I
play it the same day the signal is given.
THE RESULTS JUST MIGHT ASTOUND YOU. PLEASE GIVE ME ALL THE FEED
BACK YOU CAN AS WELL AS THE TIME PERIODS YOU FIND USEFUL.
Below you can change time periods for each of the regressions and
moving averages, as well as the max_quotes.
}
{=====================================================================}
{SET UP USER DEFINED VARIABLES}
{=====================================================================}
Ln:=5; {First Regression Time Periods}
pn:=1; {periods for first moving aver. of regression}
ln1:=5; {Second Regression Time Periods}
pn1:=2; {periods for second moving avg. of regression}
s:=1; {shift averages back}
pr:=1; {set to 1 for profit test}
gr:=1; {set to 1 to graph}
qc:=100; {set the same as max_quotes}
#MAX_QUOTES 100
{=====================================================================}
{PROFIT TESTING SETUP}
{=====================================================================}
#PROFIT_TEST both 10000 2 - next open
#profit_comm nocomm oneshare 0
#profit_output tickersummary
#output_file 'slope.lst'
{=====================================================================}
{SET UP ARRAYS AND VARIABLES}
{=====================================================================}
cx : array; {Linreg array}
cx1 : array; {Forecast array}
ccon: array; {Stores the Constant of the linreg}
cxx : array; {Slope array}
m1 : array; {Moving Averge of forecast}
m3 : array; {Moving Average of forecast}
m4: array;
cg : array; {Linreg array}
av : array;
cx11 : array; {Forecast array}
cx6 :array;
ccon1: array; {Stores the Constant of the linreg}
cxx1 : array; {Slope array}
{=====================================================================}
{LINEAR REGRESSIONS - APPROXIMATE LINES
{=====================================================================}
plot begin
{************ First Regression **********************}
st:=0;
lt:=LN;
for i=LN;i<=qc;i=i+1;
BEGIN
av:=divby(ADD(l,h),2);
cX[I] := LINREG(C,ST,LT);
ccon[i] := p[(lt-(ln-1))];
cxx[i] := SLOPE(LINREG(C,ST,LT)); {TO GET CONSTANT FROM LINREG}
cx1[i-s]:= ccon[i]+(cxx[I]*(LN+1)); {compute forecast}
sT:=ST+1;
LT:=LT+1;
end;
{*********** Second Regression ************************}
st1:=0;
lt1:=LN1;
for i=LN1;i<=qc;i=i+1;
BEGIN
cg[I] := LINREG(C,ST1,LT1);
ccon1[i] := p[(lt1-(ln1-1))];
cx6[i]=corrcoef()/100;
cxx1[i] := SLOPE(LINREG(C,ST1,LT1)); {TO GET CONSTANT FROM LINREG}
cx11[i-s]:= ccon1[i]+(cxx1[I]*(LN1+1)); {compute forecast}
ST1:=ST1+1;
LT1:=LT1+1;
end;
{=====================================================================}
{CALCULATIONS FOR CONDITIONS}
{=====================================================================}
m1:=mov(cx1,pn,'s');
m3:=mov(cx11,pn1,'s');
m4:=sub(m1,m3);
{=====================================================================}
{GRAPHS}
{=====================================================================}
le:=(qc-ln1)*(-1);
SS:=S*(-1);
if gr=1 then opengraph(2,LE,SS);
if gr=1 then sizegraph(2,1);
if gr=1 then graph(1,m1,m3);
if gr=1 then graph(cx6,'Correlation Index');
if gr=1 then closegraph();
end;
{=====================================================================}
{CONDITIONS FOR PROFIT TEST}
{=====================================================================}
bUY WHEN (m1[-1] <= m3[-1]) and (m1[0] >m3[0]){and (cx6[0]<=.1 or cx6[-1]
<=.1 or cx6[-2]<=.1)} ;
SELL WHEN (m1[-1]>= m3[-1]) and (m1[0] <m3[0]){and (cx6[0]<=.1 or cx6[-1]
<=.1 or cx6[-2]<=.1)};
stop short when (m1[-1] <= m3[-1]) and (m1[0] >=m3[0]);
stop long when (m1[-1]>= m3[-1]) and (m1[0] <=m3[0]);