You solved the problem of how to do back-testing with Bob's slope scan -- solved it beautifully, too, with a minimun of coding. And Bob worked some more of his magic on your solution. Jan and Mike asked all the right questions. My role was bumping into walls. Now the five of us will have to incorporate and issue our IPO, Scans Inc. -- the one remaining undervalued Internet company.
Here's the scan again:
// Slope by Bob Jagow //Back-testing version by Roy Yorgensen output = "linregslope.lst"; input="portfoli.lst"; issuetype common; integer i,j, S, Sx; float b,lastB, Sxx, Sxy, Sy, pctgain; S := 21; daystoload = 50 + S ; daysrequired = 2 + 10 + S; //may need for newish issues lastB:= 9999; // large first time flag won't require testing for j = -10 to 0 do // reset all variables at start of i loop Sx := 0; Sxx := 0; Sxy := 0; Sy := 0; for i = j+(1 - S) to j do Sx := Sx + i; Sy := Sy + close(i); Sxx := Sxx + i*i; Sxy := Sxy + i*close(i); next i; b := (S*Sxy - Sx*Sy)/(S*Sxx - Sx*Sx); pctgain:= (b -lastb)/abs(lastb+.0000001)*100; if pctgain > 25 then println symbol,",", date(j),",",close(j):6:3,","," B: ", b:4:3,","," LastB: ", lastb:4:3,","," Pctgain: ", pctgain:4:2; endif; lastb:=b; // save current for pctgain next j;
Brooke |