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

 Public ReplyPrvt ReplyMark as Last ReadFilePrevious 10Next 10PreviousNext  
To: Craig DeHaan who wrote (7324)10/24/1998 5:38:00 AM
From: Bob Jagow  Read Replies (3) of 11149
 
At long last, Craig, here's my [nearly still-born] step-wise LR scan.
Seems to be close to MSWIN and I've set up a virtual trust fund to
pay for unearthed bugs.
Much of the printout is just for debugging. Comments, criticisms,
suggestions and requests for enhancements will be carefully weighed
prior to rejection ;)
Bob

--------------------
// Allows 2 LRs just in case
input = "mylist.lst"; //input = "80k+vol.lst";
output = "swLR.lst";
integer i, N1, N2, Sx, Sx1, lrflag, bar, first, last;
float pa1, a1, pb1, b1, pLR1, LR1; // p denotes previous val
float pa2, a2, pb2, b2, pLR2, LR2;
float div, Sxx, Sxy, Sy, Sxx1, Sxy1, Sy1;
string lrstr;
first := 0; // Set Back test here ****
last := 0; // Set ending bar here ****
N1 := 5; // Set here ******************
N2 := 50; // Set here ******************
lrflag := 0; // Set to 0 for LRI *******
if lrflag != 0 then lrfalg:= 1; endif;
if lrflag = 0 then lrstr := "LRI: "; else lrstr := "TSF: "; endif;
Daystoload = 100 + N2; DaysRequired = 100 + N2;
// Nest any overall filters here to bypass calcs, i.e.
// if HasOptions = True then if close(first) > 5 then
Sx := 0; Sxx := 0; Sxy := 0; Sy := 0;
for i = first -1 to first -N1 step -1 do // N1 bars
Sx := Sx + i;
Sy := Sy + close(i);
Sxx := Sxx + i*i;
Sxy := Sxy + i*close(i);
next i;
Sx1 := Sx; Sy1 := Sy; Sxx1 := Sxx; Sxy1 := Sxy; // save for step wise N1
div := N1*Sxx - Sx*Sx;
pa1 := (Sxx*Sy -Sx*Sxy)/div;
pb1 := (N1*Sxy - Sx*Sy)/div;
pLR1 := pa1 + lrflag*pb1; // 1*pb if TSF

for i = first -N1 -1 to first -N2 step -1 do // N2 total bars
Sx := Sx + i; // keep at it
Sy := Sy + close(i);
Sxx := Sxx + i*i;
Sxy := Sxy + i*close(i);
next i;
div := N2*Sxx - Sx*Sx;
pa2 := (Sxx*Sy -Sx*Sxy)/div;
pb2 := (N2*Sxy - Sx*Sy)/div;
pLR2 := pa2 + lrflag*pb2; // 1*pb if TSF

for bar = first to last do // calc del for current bar
i:= bar -N2; // Replace N2 bar with current bar
Sx := Sx +bar -i;
Sy := Sy +close(bar) -close(i);
Sxx := Sxx +bar*bar -i*i;
Sxy := Sxy +bar*close(bar) -i*close(i);
div := N2*Sxx - Sx*Sx; //*********
a2 := (Sxx*Sy -Sx*Sxy)/div;
b2 := (N2*Sxy - Sx*Sy)/div;
LR2 := a2 + lrflag*b2; // 1*bcalc

// now calc LR1 using the saved values
i := bar -N1; // Replace N1 with bar ************
Sx1 := Sx1 +bar -i;
Sy1 := Sy1 +close(bar) -close(i);
Sxx1 := Sxx1 +bar*bar -i*i;
Sxy1 := Sxy1 +bar*close(bar) -i*close(i);
div := N1*Sxx1 - Sx1*Sx1;
a1 := (Sxx1*Sy1 -Sx1*Sxy1)/div;
b1 := (N1*Sxy1 - Sx1*Sy1)/div;
LR1 := a1 + lrflag*b1; // 1*bcalc
if LR1 > LR2 and pLR1 < pLR2 then // only an example
print symbol,",",date(bar),",",a1:7:3,",",pa1:7:3,",",b1:7:3,",",pb1:7:3,",",lrstr,",",LR1:7:3,",",pLR1:7:3;
println ",",a2:7:3,",",pa2:7:3,",",b2:7:3,",",pb2:7:3,",",lrstr,",",LR2:7:3,",",pLR2:7:3;
endif;
pa1:= a1; pb1:= b1; pLR1:= LR1; pa2:= a2; pb2:= b2; pLR2:= LR2;
next bar;
Report TOU ViolationShare This Post
 Public ReplyPrvt ReplyMark as Last ReadFilePrevious 10Next 10PreviousNext