Looks good, Gale. I left some unneeded variables in the float (forgot to take them out when I shortened the formula). Here's the corrected version (gives the same output, but doesn't have the unnecessary, unused variables):
//Slope of Dahl by Brooke Elise Nagler, //Using Bob Jagow's QP formula for slope
output = "dalslope3.lst"; input = "portfoli.lst"; issuetype common; Daystoload = 500;
float f, q, dalslope, Sxy, Sy; integer S, Sx, Sxx, i, j, r;
S := 13; //S is the number of days for the slope
f:=0; q:=0; for j=0 to -(S-1) step -1 do f := f + (MovAvg(j,50,cl)- MovAvg(j-15,50,cl)); //f + MovAvg(j,50,cl); next j; q:=0; for r=0 to -(S-1) step -1 do q := q+(r*(MovAvg(r,50,cl)-MovAvg(r-15,50,cl))); next r;
Sx := 0; Sxx := 0; //Sxy := 0; //Sy := 0; for i = 1 - S to 0 do Sx := Sx + i; Sy := f; Sxx := Sxx + i*i; Sxy := q; next i; dalslope := (S*Sxy - Sx*Sy)/(S*Sxx - Sx*Sx); println symbol,",",close(0):8:2,",",dalslope:8:4; |