SI
SI
discoversearch

We've detected that you're using an ad content blocking browser plug-in or feature. Ads provide a critical source of revenue to the continued operation of Silicon Investor.  We ask that you disable ad blocking while on Silicon Investor in the best interests of our community.  If you are not using an ad blocker but are still receiving this message, make sure your browser's tracking protection is set to the 'standard' level.
Strategies & Market Trends : TA-Quotes Plus

 Public ReplyPrvt ReplyMark as Last ReadFilePrevious 10Next 10PreviousNext  
To: Jan Robert Wolansky who wrote (5194)7/5/1998 10:13:00 PM
From: TechTrader42  Read Replies (1) of 11149
 
Jan, here it is at least without the "for loop," in all its obsessive
compulsive glory. I can't seem to get the values right with the for
loop yet. But the following scan does what you wanted, I think. The
first column in the output is the close, of course; the second is the
slope on the date listed; the third is the slope before that day; the
fourth is the date when the slope moved up. Because of the lack of the
for loop, it ain't one o' me proudest efforts, but it does the job:

output = "linregslope.lst";
input="portfoli.lst";

issuetype common;
Daystoload = 50; //needed for R2 bug!!!

integer i, S, Sx, Sxx;
float b, Sxy, Sy, Syb, Syc, Syd, Sye, Syf, Syg, Syh, Syi, Syj,
Sxyb, Sxyc, Sxyd, Sxye, Sxyf, Sxyg, Sxyh, Sxyi, Sxyj,
bb, bc, bd, be, bf, bg, bh, bi, bj;
S := 21;
Sx := 0;
Sxx := 0;
Sxy := 0;
Sxyb := 0;
Sxyc := 0;
Sxyd := 0;
Sxye := 0;
Sxyf := 0;
Sxyg := 0;
Sxyh := 0;
Sxyi := 0;
Sxyj := 0;
Sy := 0;

Syb := 0;
Syc := 0;
Syd := 0;
Sye := 0;
Syf := 0;
Syg := 0;
Syh := 0;
Syi := 0;
Syj := 0;
for i = 1 - S to 0 do
Sx := Sx + i;
Sy := Sy + close(i); //kills println wo d2ld
Syb := Syb + close(i-1);
Syc := Syc + close(i-2);
Syd := Syd + close(i-3);
Sye := Sye + close(i-4);
Syf := Syf + close(i-5);
Syg := Syg + close(i-6);
Syh := Syh + close(i-7);
Syi := Syi + close(i-8);
Syj := Syj + close(i-9);
Sxx := Sxx + i*i;
Sxy := Sxy + i*close(i); //kills println wo d2ld
Sxyb := Sxyb + i*close(i-1);
Sxyc := Sxyc + i*close(i-2);
Sxyd := Sxyd + i*close(i-3);
Sxye := Sxye + i*close(i-4);
Sxyf := Sxyf + i*close(i-5);
Sxyg := Sxyg + i*close(i-6);
Sxyh:= Sxyh + i*close(i-7);
Sxyi := Sxyi + i*close(i-8);
Sxyj := Sxyj + i*close(i-9);

//Sxy := Sxy + i*close(0);
next i;
b := (S*Sxy - Sx*Sy)/(S*Sxx - Sx*Sx);//Today's slope
bb := (S*Sxyb - Sx*Syb)/(S*Sxx - Sx*Sx);//Yesterday's slope
bc := (S*Sxyc - Sx*Syc)/(S*Sxx - Sx*Sx);//slope -2
bd := (S*Sxyd - Sx*Syd)/(S*Sxx - Sx*Sx);// slope -3
be := (S*Sxye - Sx*Sye)/(S*Sxx - Sx*Sx);// slope -4
bf := (S*Sxyf - Sx*Syf)/(S*Sxx - Sx*Sx);// slope -5
bg := (S*Sxyg - Sx*Syg)/(S*Sxx - Sx*Sx);// slope -6
bh := (S*Sxyh - Sx*Syh)/(S*Sxx - Sx*Sx);//slope -7
bi := (S*Sxyi - Sx*Syi)/(S*Sxx - Sx*Sx);// slope -8
bj := (S*Sxyj - Sx*Syj)/(S*Sxx - Sx*Sx);// slope -9

if b > bb then
println symbol,",",close(0):8:2,",",b:8:3,",", bb:8:3,", ", date(0);
if bb > bc then
println symbol,",",close(0):8:2,",",b:8:3,",", bb:8:3,", ", date(-1);
if bc > bd then
println symbol,",",close(0):8:2,",",b:8:3,",", bb:8:3,", ", date(-2);
if bd > be then
println symbol,",",close(0):8:2,",",b:8:3,",", bb:8:3,", ", date(-3);
if be> bf then
println symbol,",",close(0):8:2,",",b:8:3,",", bb:8:3,", ", date(-4);
if bf > bg then
println symbol,",",close(0):8:2,",",b:8:3,",", bb:8:3,", ", date(-5);
if bg > bh then
println symbol,",",close(0):8:2,",",b:8:3,",", bb:8:3,", ", date(-6);
if bh > bi then
println symbol,",",close(0):8:2,",",b:8:3,",", bb:8:3,", ", date(-7);
if bi > bj then
println symbol,",",close(0):8:2,",",b:8:3,",", bb:8:3,", ", date(-8);
endif; endif; endif; endif; endif; endif; endif; endif; endif;

// or bb>bc or bc>bd or bd>be or be>bf or bf>bg or bg> bh or bh>bi or bi>bj then
// println symbol,",",close(0):8:2,",",b:8:3,",", bb:8:3,",",bc:8:3,",",bd:8:3,",",be:8:3
//,",",bf:8:3,",",bg:8:3,",",bh:8:3,",",bi:8:3,",",bj:8:3;
//endif;
Report TOU ViolationShare This Post
 Public ReplyPrvt ReplyMark as Last ReadFilePrevious 10Next 10PreviousNext