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: Webb B Blackman Jr who wrote (7838)11/17/1998 2:02:00 PM
From: TechTrader42  Read Replies (1) of 11149
 
I modified it to show only sell signals, ie. SAR below price

Webb: You'd better check your scan, as Richard says. When SAR falls below the price, it's a buy signal. Take a look at SAR in Metastock, and you'll see.

Someone inadvertently mixed up the buy and sell signals in one of the SAR scans posted on this thread, I seem to remember. The error was fixed quickly. You might want to make sure you have the correct version. Here it is:

//SAR, by Jeff Grover (with some changes by Bob Jagow)
input = "portfoli.lst";
output = "sar.lst";
float accdelta, accfac, SIP, SAR, SARp, xprice;
integer j, count, buysell,firstday, flipday;
accdelta := .02;
accfac := accdelta;
count := -100;
buysell := 0; // 1-long, 0-short
firstday := 1;
SAR := high(count);
SARp := SAR;
SIP := SAR;
xprice := high(count);

for j = count-1 to 0 step 1 do
if( buysell = 0 ) then // short position
if( firstday = 1 ) then
SAR := SIP;
firstday := 0;
else
if( low(j) < xprice ) then
xprice := low(j);
if( accfac < .2 ) then accfac := accfac + accdelta; endif;
endif;
SAR := SARp - accfac * abs(xprice - SARp);
endif;

if( SAR <= high(j) or SAR <= high(j-1) ) then
if( high(j) >= high(j-1)) then SAR := high(j);
else SAR := high(j-1); endif;
buysell := 1;
flipday:= j;
accfac := accdelta;
SIP := xprice;
firstday := 1;
endif;
endif;

if( buysell = 1 ) then // long position
if( firstday = 1 ) then
SAR := SIP;
firstday := 0;
else
if( high(j) > xprice ) then
xprice := high(j);
if( accfac < .2 ) then accfac := accfac + accdelta; endif;
endif;
SAR := SARp + accfac * abs(xprice - SARp);
endif;

if( SAR >= low(j) or SAR >= low(j-1) ) then
if( low(j) <= low(j-1)) then SAR := low(j);
else SAR := low(j-1); endif;
buysell := 0;
flipday:= j;
accfac := accdelta;
SIP := xprice;
firstday := 1;
endif;
endif;

SARp := SAR;
next j;

if buysell = 0 then println symbol," Sell on ",
date(flipday),",",close(flipday):6:3; endif;
if buysell = 1 then println symbol," Buy on ",
date(flipday),",",close(flipday):6:3; endif;
Report TOU ViolationShare This Post
 Public ReplyPrvt ReplyMark as Last ReadFilePrevious 10Next 10PreviousNext