Here's a new scan for the MA of dahl. You can put any days in: //MA of Dahl by Brooke Elise Nagler
output="dahlma.lst";
DaysToLoad=100; integer j, k; float days, f, i, dahlma; days :=21;//number of days for moving average
f:=0; i:=0; for j=0 to -(days-1) step -1 do f := f + MovAvg(j,50,cl); i := i + MovAvg(j-15,50,cl); next j; dahlma:=(f-i)/days;
println symbol , "," ,dahlma;
**********************
And here's a scan that looks for stocks with the MA of Dahl going up through 0:
//Dahl MA (with loop) crossing up through 0, Brooke Elise Nagler
output="dahlup.lst";
DaysToLoad=100;
integer j, k, l, o;
float days, f, i, m, p, dahlma, prevdama; days :=21;//number of days for moving average
f:=0; i:=0; for j=0 to -(days-1) step -1 do f := f + MovAvg(j,50,cl); i := i + MovAvg(j-15,50,cl); next j; dahlma:=(f-i)/days;
//for previous day's dahl: m:=0; p:=0; for l=-1 to -days step -1 do m := m + MovAvg(l,50,cl); p := p + MovAvg(l-15,50,cl); next l;
prevdama := (m-p)/days;
if dahlma>0 and prevdama<0 then println Symbol , "," , " dahlma:", dahlma , "," ," Close:", Close(0) , "," , " Vol:", vol(0) , " , " , " PE:", PE , " , " , " QRS:", QRS(0) , "," , " Sharesfloat:", Sharesfloat , "," , description; endif;
*********************
And here's a shortened version (wtih the new for loop coding for slope of Dahl) of BPS (Brooke's Penurious System -- or Percentage System, if you like):
//Brooke's Percentage System, Sell Signal, //Use with Buy Signal for percentage gain in price; //Based on Bob Jagow's QP formula for linear regreession slope; //Paul Beattie's QP formula for DNS; //Brooke's QP formula for Dahl's Primary Trend; and StDev.
Output="bpssell.lst";
DaysToLoad=250; Integer D, i, S, Sx, Sxx, j, r; Float A0,A1,A2,A3,A4,A5,A6,A7,A8, f, q, dalslope, Sxy, Sy;
A8:=(wMovavg(-8,8,cl)-wMovavg(-8,17,cl))*1; // Multiplied to make a weighted MA A7:=(wMovavg(-7,8,cl)-wMovavg(-7,17,cl))*2; // Multiplied to make a weighted MA A6:=(wMovavg(-6,8,cl)-wMovavg(-6,17,cl))*3; // Multiplied to make a weighted MA A5:=(wMovavg(-5,8,cl)-wMovavg(-5,17,cl))*4; // Multiplied to make a weighted MA A4:=(wMovavg(-4,8,cl)-wMovavg(-4,17,cl))*5; // Multiplied to make a weighted MA A3:=(wMovavg(-3,8,cl)-wMovavg(-3,17,cl))*6; // Multiplied to make a weighted MA A2:=(wMovavg(-2,8,cl)-wMovavg(-2,17,cl))*7; // Multiplied to make a weighted MA A1:=(wMovavg(-1,8,cl)-wMovavg(-1,17,cl))*8; // Multiplied to make a weighted MA A0:=(wMovavg(0,8,cl)-wMovavg(0,17,cl))*9; // Multiplied to make a weighted MA
D:=0; // 5 day WMA is greater than the 13 day WMA If wMovavg(0,5,cl)>wMovavg(0,13,cl) then D := D +1; endif; // 13 day WMA is greater than the 40 day WMA If wMovavg(0,13,cl)>wMovavg(0,40,cl)then D := D +1; endif; // 50 day MA is greater than the 50 day MA 15 days ago If Movavg(0,50,cl)-Movavg(-15,50,cl)>0 then D := D +1; endif; // OBV greater than its 40 day simple moving average If OBV(0)>Movavg(0,40,OBV) then D := D+1; endif; // Vol greater than 120 day simple moving average If Vol(0)>Movavg(0,120,Vol) then D := D+1; endif; // Divided by 45 for weighted moving average If wMovavg(0,8,cl)-wMovavg(0,17,cl)>(A0+A1+A2+A3+A4+A5+A6+A7+A8)/45 then D:= D + 1; endif; // If((Mov(ROC(C,12,%),3,E)>=-6 OR ROC(C,12,%)>0),1,0)+1,0) If wMovavg(0,3,ROC) >=-6 or ROC(0)>0 then D := D+1; endif;
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);
if D<=3 and dalslope<0 and StDev(0,-20)>.25 then println symbol:-6," SELL: Close: ", close(0):-6:3, ",", " Up/Down: ", close(0)-close(-1):4:3, ","," Volume: ", vol(0):-10, ",", " QRS: ", QRS(0):2, ","," Sharesfloat: ", Sharesfloat:6:3, ", ",Description:-12; endif;
*****************
Finally, here's a simple one for computing Dahl:
//Dahl by Brooke Elise Nagler
//mov(c,days,simp) - ref(mov(c,days,simp),-15)
output="dahl.lst";
daystoload = 250; float dahl, prevdahl;
dahl := movavg(0,50,cl)-movavg(-15,50,cl); prevdahl := movavg(-1,50,cl)-movavg(-16,50,cl);
println Symbol , "," , "dahl:", dahl , "," ,"prevdahl:", prevdahl; |