SI
SI
discoversearch

We've detected that you're using an ad content blocking browser plug-in or feature. Ads provide a critical source of revenue to the continued operation of Silicon Investor.  We ask that you disable ad blocking while on Silicon Investor in the best interests of our community.  If you are not using an ad blocker but are still receiving this message, make sure your browser's tracking protection is set to the 'standard' level.
Strategies & Market Trends : TA-Quotes Plus -- Ignore unavailable to you. Want to Upgrade?


To: Gale A. Thompson who wrote (3082)1/15/1998 8:11:00 PM
From: TechTrader42  Read Replies (3) | Respond to of 11149
 
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;



To: Gale A. Thompson who wrote (3082)1/15/1998 8:27:00 PM
From: TechTrader42  Respond to of 11149
 
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;



To: Gale A. Thompson who wrote (3082)1/15/1998 8:41:00 PM
From: Bob Jagow  Read Replies (1) | Respond to of 11149
 
Gale,
You asked [and then answered ;)] "How would I filter for a particular value of the slope?]
Since your println is properly formatted for sorting, why not get them all and look at the dahlslope-sorted data to decide where to make the cut?

(You can save the sorted spreadsheet under a different name and cut/paste the desired ranges for further tests.)

-bob