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: Roy Yorgensen who wrote (5208)7/6/1998 8:59:00 PM
From: Bob Jagow  Read Replies (1) 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;
Report TOU ViolationShare This Post
 Public ReplyPrvt ReplyMark as Last ReadFilePrevious 10Next 10PreviousNext