To: Craig DeHaan who wrote (7133 ) 10/11/1998 4:37:00 PM From: Bob Jagow Read Replies (1) | Respond to of 11149
Craig, SAR is often called Parabolic SAR in the lit. The pSAR in Jeff's scan is the previous day's value of SAR. What I posted for the SAR crossing was wrong BTW, and I can't see how to use your Cross(C, SAR, 0.02,0.2)) ... comment -- should just need to print the day that buysell flips, but it looks like that gives the buy 1 day early. I am in the process of changing the code to Kaufman's initialization (pick a hi/low with max/min and set SIP to that value. -Bob --------------- //Parabolic SAR, 10 Jan 1998 // by Jeff Grover input = "30k+vol.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," Buy on ", date(flipday),",",close(flipday):6:3; endif; if buysell = 1 then println symbol," Sell on ", date(flipday),",",close(flipday):6:3; endif;