Bob: Here is the "Sy" part of the dahl slope formula with the for loop. The "Sxy" part is presenting difficulties, to say the least.
f:=0; for j=0 to -2 step -1 do f := f + MovAvg(j,50,cl); next j; z:=0; for k=-15 to -17 step -1 do z := z + MovAvg(k,50,cl); next k; Sy := (f-z);
That works well, and the output is correct.
For the Sxy part, I've been playing with something like this:
q:=0; for r=0 to -2 step -1 do q := q+(r*(MovAvg(r,50,cl)-MovAvg(k,50,cl))); next r;
But it doesn't give the right values, maybe because there's no "next k" in there. But QP won't accept another next k. I've tried combining everything into one for loop, but either I get errors, or the values aren't right.
I've tried all sorts of formulas, but none checks against the original value of Sxy with the longer formula (that value is the same as the value given by WOW). Theoretically, the for loop above would work, if r and k did their stuff and got moving.
Sxy, remember, is: (0*dahl)+(-1*dahla)+(-2*dahlb);
where:
dahl := (aa-bb); dahla := (cc-dd); dahlb := (ee-ff);
and:
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) ;
Brooke
The whole long formula for the slope of dahl was:
output = "dalslope3.lst"; input = "portfoli.lst"; issuetype common; Daystoload = 500;
//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:4; |