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: Roy Yorgensen who wrote (5208)7/6/1998 7:19:00 PM
From: TechTrader42  Respond to of 11149
 
I don't think this scan needs the DaystoLoad function. That line was put in for an earlier version of QP2, one of the beta versions. Now you can delete it, and the values will remain the same. Some scans do require DaystoLoad, of course, but not this one.

I saw the "00/00/00," too, when I deleted the "j<0" line and kept "i" in the date. But you won't get the 0 date if you change date(i) to date(j).

The formula finds the slope of the price line, using the linear regression formula that Metastock uses. Window on Wall Street's "slope" gives the same values. The values for the QP scan match theirs, too.

Thanks for the terrific back-testing version of the slope scan. It works beautifully. You certainly do nice coding for a "beginner" -- your solution was Hemingwayesque in its directness and simplicity -- when I was at sea.

Brooke



To: Roy Yorgensen who wrote (5208)7/6/1998 7:46:00 PM
From: Michael Quarne  Read Replies (2) | Respond to of 11149
 
HI Roy,

Boy what a Scan, I got 38328 hits with it.

Would it be useful to put a filter in that would print only the highest hit and date? Hits that are above trigger line? Perhaps there are others as well.

Arctic Mike



To: Roy Yorgensen who wrote (5208)7/6/1998 8:59:00 PM
From: Bob Jagow  Read Replies (1) | Respond to of 11149
 
The formula just fits a least-square line thru the points, Roy.
There is a bug as writen -- Sxx must be declared float to
avoid overflow for large S.
It will be pretty slow for large S and extensive backtesting -- more
efficient in that case to replace the oldest point rather than summing
x, y, and xy anew.
(No need to recalc Sxx -- the denominator, S*Sxx - Sx*Sx, stays constant.)
You need to be sure there are enough days, but daystoload isn't
sufficient -- you need to set daysrequired = maxperiod + daysback.
FWIW the template I use to switch backtesting on/off follows. -Bob

------------
input="input.lst";
output = "output.lst";
integer i, day, first, last, MaxPrday, maxperiod;
float MaxGain, MaxPr;
maxperiod:= 50; // based on longest indicator period
first:= -120; // Set to < last to test from there to last
daystoload = 100 + maxperiod - first;
DaysRequired = maxperiod - first; //Newer issues will be skipped
last:= -20; // days
if first >= last then last:= first; endif; // disable the for loop
// i.e., first:= -20 just tests 20 days ago
// and first:=0 disables Back Testing
for day = first to last do
if cond1 then
if cond2 then
if cond3 then
if cond4 then
if cond5 then
if cond6 then // etc.
print symbol,",",date(day),",",close(day):8:3;
if first != 0 then //measure performance
MaxPr:= max(0, day+1, cl); //till day 0
MaxGain:= (MaxPr -close(day))/close(day);
for i = day+1 to 0 do //find first max then exit the loop
if close(i) >= MaxPr then
MaxPrday:= i;
i:= 0;
endif;
next i;
print",",date(MaxPrday),",",100*MaxGain:8:1;
println; // everything else for excel or perl backtest
endif; //first
endif; endif; endif; endif; endif; endif;
next day;



To: Roy Yorgensen who wrote (5208)7/6/1998 9:04:00 PM
From: TechTrader42  Respond to of 11149
 
Roy: I think you were right with "i" in the date() after all. I didn't understand what you were doing with "b" and "b1." You have "b" as the previous day and "b1" as the day of the date, or date(i) -- in other words, the day of the hit, when the condition is true. So for DELL, if I put "b" and "b1" in the output, the value of "b1" on 7/01 is .65. B is the value on the previous day.

DELL ,07/01/1998, 92.88, B: 0.61, B1: 0.65

Of course, that's why you have if b<b1 when you're looking for slope moving up. B is the first value, and B1 is the "next j."

So the scan should be the way you had it, with q<0 and date(i). I've just changed the output to show B1:

println symbol,",", date(i),",",close(0):6:2,","," B: ", b:4:2,","," B1: ", b1:4:2;

Here's the whole thing again:

//Slope formula by Bob Jagow
//Back-testing version by Roy Yorgensen
output = "linregslope.lst";
input="portfoli.lst";
issuetype common;
//Daystoload = 50; //needed for R2 bug!!!
integer i,j, S, Sx, Sxx;
float b,b1, Sxy, Sy;
b1:=0; // only initialized first time
for j = 0 to -10 step -1 do
// reset all variables at stat of next loop
S := 21;
Sx := 0;
Sxx := 0;
Sxy := 0;
Sy := 0;
for i = j+(1 - S) to j do
Sx := Sx + i;
Sy := Sy + close(i); //kills println wo d2ld
Sxx := Sxx + i*i;
Sxy := Sxy + i*close(i); //kills println wo d2ld
//Sxy := Sxy + i*close(0);
next i;
b := (S*Sxy - Sx*Sy)/(S*Sxx - Sx*Sx);
if
j<0 and // eliminate first pass thru loop
b< b1 then
//println symbol,",", date(i),",",close(0):8:2,",",b:8:4;
println symbol,",", date(i),",",close(0):6:2,","," B: ", b:4:2,","," B1: ", b1:4:2;
b1:=b; // save current for next test
else
b1:=b; // must alway set ot last day's val
endif;
next j;

Brooke