Jan: I'm on my way out (in more ways than one), so I'll just give you a scan that does part of what you wanted. I hope this part is right, since it's a quick effort. This gives stocks whose 21-day slope was higher today than the day before. I'll be back later to do it for the past 10 days, if you haven't figured that out by then. (You'd have to do a back testing version that moved "i" back 1 day at a time for 10 days. You could add another variable to the scan to do this -- one that moved back 10 days).
But here it is without the 10-day back-testing. This gives the slope yesterday and today (I hope):
output = "linregslope.lst";
issuetype common; Daystoload = 50; //needed for R2 bug!!! integer i, S, Sx, Sxx; float b, Sxy, Sy, Syb, Sxyb, bb; S := 21; Sx := 0; Sxx := 0; Sxy := 0; Sxyb := 0; Sy := 0; Syb := 0; for i = 1 - S to 0 do Sx := Sx + i; Sy := Sy + close(i); //kills println wo d2ld Syb := Syb + close(i-1); //kills println wo d2ld Sxx := Sxx + i*i; Sxy := Sxy + i*close(i); //kills println wo d2ld Sxyb := Sxyb + i*close(i-1); //kills println wo d2ld //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 if b > bb then println symbol,",",close(0):8:2,",",b:8:4,",", bb:8:4; endif;
|