Bob: Here's a QP translation of a system I occasionally use in Window on Wall Street -- a translation that makes use of your brilliant QP formula for a linear regression slope. It's based on percentage jumps in price. It works best with low-cap stocks. The slope of Dahl is in there to prevent buying after up days when a stock is trending down. It ain't the Holy Grail, but it finds some nice picks.
//Brooke's Percentage System
output = "bps.lst"; input = "portfoli.lst"; issuetype common; Daystoload = 500;
//dahl: mov(c,days,simp) - ref(mov(c,days,simp),-15)
float a, b, c, d, e, f, dahl, prevdahl, nextdahl, dalslope, Sxy, Sy; integer i, S, Sx, Sxx;
a := movavg(0,50,cl) ; b := movavg(-15,50,cl) ; c := movavg(-1,50,cl) ; d := movavg(-16,50,cl) ; e := movavg(-2,50,cl) ; f := movavg(-17,50,cl) ;
dahl := (a-b); prevdahl := (c-d); nextdahl := (e-f);
S := 3; Sx := 0; Sxx := 0; //Sxy := 0; //Sy := 0; for i = 1 - S to 0 do Sx := Sx + i; Sy := dahl + prevdahl + nextdahl; Sxx := Sxx + i*i; Sxy := (0*dahl)+(-1*prevdahl)+(-2*nextdahl); next i; dalslope := (S*Sxy - Sx*Sy)/(S*Sxx - Sx*Sx);
if close(0)>1.03*close(-1) and dalslope>0 then println symbol:-6," BUY: Close: ", close(0):-6:3, ",", " Up: ", close(0)-close(-1):4:3, ","," Volume: ", vol(0):-10, ",", " QRS: ", QRS(0):2, ","," Sharesfloat: ", Sharesfloat:6:3, ", ",Description:-12; endif;
*********************************
Here's is a formula for the 3-day slope of Dahl's Primary Trend, which uses Bob's QP formula for slope. Incrediby, it gives the same values as WOW for the slope of Dahl (thank you Bob for the slope formula!):
//3-day Slope of Dahl's Primary Trend, applying Bob Jagow's //slope formula to Brooke's Dahl formula output = "dalslope.lst";
issuetype common; Daystoload = 500;
//Dahl: mov(c,days,simp) - ref(mov(c,days,simp),-15)
float a, b, c, d, e, f, dahl, prevdahl, nextdahl, slope, Sxy, Sy; integer i, S, Sx, Sxx;
a := movavg(0,50,cl) ; b := movavg(-15,50,cl) ; c := movavg(-1,50,cl) ; d := movavg(-16,50,cl) ; e := movavg(-2,50,cl) ; f := movavg(-17,50,cl) ;
dahl := (a-b); prevdahl := (c-d); nextdahl := (e-f);
S := 3; Sx := 0; Sxx := 0; //Sxy := 0; //Sy := 0; for i = 1 - S to 0 do Sx := Sx + i; Sy := dahl + prevdahl + nextdahl; Sxx := Sxx + i*i; Sxy := (0*dahl)+(-1*prevdahl)+(-2*nextdahl); next i; slope := (S*Sxy - Sx*Sy)/(S*Sxx - Sx*Sx); println symbol,",",close(0):8:2,",",slope:8:2;
****************
That scan is based on Bob Jagow's simple and elegant translation of the MSWIN linear regression formula for slope:
//Slope, formulated by Bob Jagow
output = "slopebob.lst";
issuetype common; Daystoload = 50; //needed for R2 bug!!! integer i, S, Sx, Sxx; float b, Sxy, Sy; S := 2; Sx := 0; Sxx := 0; Sxy := 0; Sy := 0; for i = 1 - S to 0 do Sx := Sx + i; Sy := Sy + close(i); //kills println wo d2ld Sxx := Sxx + i*i; Sxy := Sxy + i*close(i); //kills println wo d2ld //Sxy := Sxy + i*close(0); next i; b := (S*Sxy - Sx*Sy)/(S*Sxx - Sx*Sx); println symbol,",",close(0):8:2,",",b:8:2;
*******************
That's it folks. No more linear regressions or linear obsessions for the time being.
Brooke |