Your formula is completely adaptable for Dahl, too. Below is a QP formula for the 13-day linear regression slope of Dahl. For BNGO, the formula gives a value of -0.0175. That's the same value that WOW gives with this formula: slope(fml("Dahl's primary trend"),13), where Dahl's Primary Trend is: mov(c,50,s) - ref(mov(c,50,s),-15).
Here's the QP formula:
//13-day linear regression slope of Dahl
Output="daslope13.lst";
DaysToLoad=250; Integer i, S, Sx, Sxx; Float aa, bb, cc, dd, ee, ff, gg, hh, ii, jj, kk, ll, mm, nn, oo, pp, qq, rr, ss, tt, uu, vv, ww, xx, yy, zz, dahl, dahla, dahlb, dahlc, dahld, dahle, dahlf, dahlg, dahlh, dahli, dahlj, dahlk, dahll, dalslope, Sxy, Sy;
aa := movavg(0,50,cl) ; bb := movavg(-15,50,cl) ; cc := movavg(-1,50,cl) ; dd := movavg(-16,50,cl) ; ee := movavg(-2,50,cl) ; ff := movavg(-17,50,cl) ; gg := movavg(-3,50,cl) ; hh := movavg(-18,50,cl) ; ii := movavg(-4,50,cl) ; jj := movavg(-19,50,cl) ; kk := movavg(-5,50,cl) ; ll := movavg(-20,50,cl) ; mm := movavg(-6,50,cl) ; nn := movavg(-21,50,cl) ; oo := movavg(-7,50,cl) ; pp := movavg(-22,50,cl) ; qq := movavg(-8,50,cl) ; rr := movavg(-23,50,cl) ; ss := movavg(-9,50,cl) ; tt := movavg(-24,50,cl) ; uu := movavg(-10,50,cl) ; vv := movavg(-25,50,cl) ; ww := movavg(-11,50,cl) ; xx := movavg(-26,50,cl) ; yy := movavg(-12,50,cl) ; zz := movavg(-27,50,cl) ;
dahl := (aa-bb); //dahl(0) dahla := (cc-dd); //dahl(-1) dahlb := (ee-ff); //dahl(-2) dahlc := (gg-hh); //dahl(-3) dahld := (ii-jj); //dahl(-4) dahle := (kk-ll); //dahl(-5) dahlf := (mm-nn); //dahl(-6) dahlg := (oo-pp); //dahl(-7) dahlh := (qq-rr); //dahl(-8) dahli := (ss-tt); //dahl(-9) dahlj := (uu-vv); //dahl(-10) dahlk := (ww-xx); //dahl(-11) dahll := (yy-zz); //dahl(-12)
S := 13; Sx := 0; Sxx := 0; //Sxy := 0; //Sy := 0; for i = 1 - S to 0 do Sx := Sx + i; Sy := dahl + dahla + dahlb + dahlc + dahld + dahle + dahlf + dahlg + dahlh + dahli +dahlj + dahlk + dahll; Sxx := Sxx + i*i; Sxy := (0*dahl)+(-1*dahla)+(-2*dahlb)+(-3*dahlc)+(-4*dahld)+(-5*dahle)+(-6*dahlf)+(-7*dahlg)+(-8*dahlh)+(-9*dahli)+(-10*dahlj)+(-11*dahlk)+(-12*dahll); next i; dalslope := (S*Sxy - Sx*Sy)/(S*Sxx - Sx*Sx);
println symbol,",",close(0):8:2,",",dalslope:8:4;
Brooke |