logo
Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

2 Pages12>
Options
Go to last post Go to first unread
mkz  
#1 Posted : Monday, August 8, 2005 3:11:13 AM(UTC)
mkz

Rank: Member

Groups: Registered, Registered Users
Joined: 8/8/2005(UTC)
Posts: 12

What is the Equis formula for calculating SAR? Or any other?
crwinnr5  
#2 Posted : Thursday, August 11, 2005 7:34:31 PM(UTC)
crwinnr5

Rank: Advanced Member

Groups: Registered, Registered Users
Joined: 7/21/2005(UTC)
Posts: 74
Location: Oklahoma USA

I would also like to know the actual Equis SAR formula.
StorkBite  
#3 Posted : Thursday, August 11, 2005 7:45:09 PM(UTC)
StorkBite

Rank: Advanced Member

Groups: Registered, Registered Users
Joined: 3/19/2005(UTC)
Posts: 2,995

Was thanked: 14 time(s) in 10 post(s)
For the SAR indicator, check out p.108 in the Primer: Syntax: SAR(Step, Maximum). For more information, a forum search query: 'SAR' results in at least a dozen hits. Google will give you dozens more.
crwinnr5  
#4 Posted : Thursday, August 11, 2005 8:00:23 PM(UTC)
crwinnr5

Rank: Advanced Member

Groups: Registered, Registered Users
Joined: 7/21/2005(UTC)
Posts: 74
Location: Oklahoma USA

Perhaps I may have overlooked it, but my research hasn't given me the actual method of how the SAR is computed - I even have Wilder's book - but no formula. The only thing I have found is how to adjust the default SAR from SAR(.02, .2) to whatever you want it to be. I need the actual MS formula for some testing I have in mind. I do have the following formula but I am having trouble with the Extreme Price and how MSFL handles it. "Once the market establishes a direction, the initial SAR becomes the extreme price for the two intervals. The extreme price is either the lowest price or highest price for the two trading intervals. The short position uses the high, and the long position uses the low. The universal formula for the SAR is: SARt = SARt-1 + ( a * ( EPtrade - SARt-1) ) SARt is the stop and reverse price for the current interval. SARt-1 is the stop and reverse price for the previous interval. a is the acceleration factor. EPtrade is the extreme price for the trade." Any additional help would be appreciated.
Patrick  
#5 Posted : Thursday, August 11, 2005 8:25:25 PM(UTC)
Patrick

Rank: Advanced Member

Groups: Registered, Registered Users, Subscribers
Joined: 9/8/2004(UTC)
Posts: 2,266

Was thanked: 1 time(s) in 1 post(s)
crwinnr5 and all others who want the SAR ... A lot of people have been asking about it ... Yes I should be able to figure it out for you guys.But let me just finish a few other things first and then I will to create either a MetaStock Formula that recalculates it properly or at worst explain what the calculation does. Patrick :mrgreen:
crwinnr5  
#6 Posted : Thursday, August 11, 2005 9:26:11 PM(UTC)
crwinnr5

Rank: Advanced Member

Groups: Registered, Registered Users
Joined: 7/21/2005(UTC)
Posts: 74
Location: Oklahoma USA

Thanks Patrick and Stockman. I am using EOD MS 9.1 with XP Pro. Here is one thing I am trying to resolve. For the NDX on 08/03/05 the SAR(.05,.2) was 1604.58. The SAR reversed on 08/04/05 to 1628.57 (which is the EP (or HHV) of 08/02/05. Unfortunately, in reality, Metastock does not display the SAR for 08/04/05 on 08/03/05. Roughly it should have been somewhere around 1606.612 because the reversal was triggered by the LLV on 08/04/05 of 1606.60. What I am after is a forward computaton of the SAR done by MSFL. Also, with your help Patrick, a more in-depth understanding of how the SAR is computed. I am using an old DOS software package that does compute the next days SAR but with the new XP OS, the old DOS software is having some issues. I would like to compute the next days SAR in Metastock. I would also like to transfer all the items from the old software to MS, but that is for another day. Charley
Patrick  
#7 Posted : Thursday, August 11, 2005 9:30:12 PM(UTC)
Patrick

Rank: Advanced Member

Groups: Registered, Registered Users, Subscribers
Joined: 9/8/2004(UTC)
Posts: 2,266

Was thanked: 1 time(s) in 1 post(s)
Well I created a "Dynamic" SAR function as a dll ( Matches Metastock values when using static data )... The SAR is really weird ... Well the SAR already is calculating the value for the next day but maybe I could add an option to calculate the value for in 5 days ... Interresting ... I will geek out on it later. I will keep you posted. Patrick :mrgreen:
crwinnr5  
#8 Posted : Thursday, August 11, 2005 9:57:13 PM(UTC)
crwinnr5

Rank: Advanced Member

Groups: Registered, Registered Users
Joined: 7/21/2005(UTC)
Posts: 74
Location: Oklahoma USA

Patrick, if you could get MSFL to go out 5 days that would be just fantistic! Here is a tid bit that may help us. I think Wilder's software package is using his Adam Reversal Theory (I believe this also referred to as price inversion) to compute the next days SAR (because to compute the SAR you do need a High and Low price). If I can be of any help let me know since I have been toying with this some. Charley
StorkBite  
#9 Posted : Thursday, August 11, 2005 10:02:28 PM(UTC)
StorkBite

Rank: Advanced Member

Groups: Registered, Registered Users
Joined: 3/19/2005(UTC)
Posts: 2,995

Was thanked: 14 time(s) in 10 post(s)
P, did any of those scripts help you out or what? I've exhausted everything I have access to... except you. Are you exhausted yet? :P
Patrick  
#10 Posted : Thursday, August 11, 2005 11:39:02 PM(UTC)
Patrick

Rank: Advanced Member

Groups: Registered, Registered Users, Subscribers
Joined: 9/8/2004(UTC)
Posts: 2,266

Was thanked: 1 time(s) in 1 post(s)
What scripts,G? :oops:
Quote:
Adam Reversal Theory (I believe this also referred to as price inversion) to compute the next days SAR (because to compute the SAR you do need a High and Low price)
I think you might be right because all the calculations use high and low values except for the initialisation which is the close value. Patrick :mrgreen:
Patrick  
#11 Posted : Friday, August 12, 2005 12:06:51 AM(UTC)
Patrick

Rank: Advanced Member

Groups: Registered, Registered Users, Subscribers
Joined: 9/8/2004(UTC)
Posts: 2,266

Was thanked: 1 time(s) in 1 post(s)
What did you want to test? ... Right now I changed the calculations to use a data array of my choice instead of high and low ... But ultimately you are the one who wants to mess with it. Let me know :D By the way it uses loops all over so it can't be coded in MS language. Patrick :mrgreen:
crwinnr5  
#12 Posted : Friday, August 12, 2005 2:51:54 PM(UTC)
crwinnr5

Rank: Advanced Member

Groups: Registered, Registered Users
Joined: 7/21/2005(UTC)
Posts: 74
Location: Oklahoma USA

Thanks Patrick, my need for the SAR formula actually came up when I wanted to test a split trade in Metastock. I upgraded to 9.1 for the Enhanced System Tester in hope that I could test my concept. But your reply to my previous post indicated the split trade cannot be tested in Metastock. I was able to test the concept using Excel and transfering the SAR data to Excel. My desire then was to compute the SAR in Excel, thus the need for the Equis formula. I have created the SAR in Excel using another formula but to date I cannot match the number generated by Metastock. I appreciate your efforts in helping me resolve this issue but sadly it appears MSFL just cannot handle this. The actual Metastock SAR formula would still be appreciated.
pumrysh  
#13 Posted : Saturday, August 13, 2005 1:51:40 AM(UTC)
pumrysh

Rank: Advanced Member

Groups: Registered, Registered Users, Subscribers
Joined: 10/28/2004(UTC)
Posts: 110

All, I would still like to see the calculation for the P SAR. I have done a hand calculation and found that the formula must use the lowest low and highest high for a given period. I'm not sure if that would be the LLV/HHV function or just the Lowest/Highest Since Bars Ago. Either way I was pleased to get the hand calculation to work. In the chart that I did the hand calc on I did find what I thought could be an error. I'll try to upload a pic so you can see what I'm talking about. Patrick, you are right, the calculation does give the value for the next day. Too bad it won't plot into the future. The Long code goes like this: The trade is initiated with the Lowest low as the first value of the SAR. From that point the calculation is SAR(tomorrow)=SAR(today) + AF*(Highest High-SAR(today) AF is the acceration factor or step value My thinking is that if I can hand calculate it I should be able to code it Preston
pumrysh  
#14 Posted : Saturday, August 13, 2005 2:01:19 AM(UTC)
pumrysh

Rank: Advanced Member

Groups: Registered, Registered Users, Subscribers
Joined: 10/28/2004(UTC)
Posts: 110

Hand calculation chart
Patrick  
#15 Posted : Tuesday, August 16, 2005 8:54:40 PM(UTC)
Patrick

Rank: Advanced Member

Groups: Registered, Registered Users, Subscribers
Joined: 9/8/2004(UTC)
Posts: 2,266

Was thanked: 1 time(s) in 1 post(s)
Here is the sar calculation : [code:1:7a933bb5a3] void PASCAL Calc_ParabolicSAR(struct Data_rec *Data, struct DataInfo_rec *psDest, float fStep, float maximum) { int lp; // 'Loop' variable to loop thru all data. float ep, epYesterday; // Column #2, Extreme Price. float diff; // Column #3, difference between EP and SAR. float af; // Column #4, Acceleration Factor. float af_x_diff; // Column #5, AF times DIFF. float nextSAR; // This is the highest high during a long trade or the // lowest low during a short trade. It becomes the next // SAR value after a trade occurs. BOOL longPos; // TRUE if in a long trade, FALSE if short. BOOL firstValidTrade; // The first trade is assumed to be invalid. This // variable keeps track of the second trade (ie, the // first valid trade) so we can inform the caller. float initTotal; // Used to total the first MIN_DAYS-1 of data to see // what general trend is. # define MIN_DAYS 15+1 // Minimum number of days of data to determine // first trade. # ifdef SNINclc2_TRACE FILE *traceFile; #define TRACE_FILE_NAME "TRACE" #endif if( NoData( Data->Clse.FirstValid, Data->Clse.LastValid, &psDest->FirstValid, &psDest->LastValid ) ) return; if ( Data->Clse.LastValid > MIN_DAYS ) { /*---------------------------------------------*/ /* Initialze day #1. This was written based on*/ /* Mr. Wilder's comments on page 16. */ /*---------------------------------------------*/ firstValidTrade = 0; psDest->FirstValid = psDest->LastValid = Data->Clse.LastValid; initTotal = 0.0f; /*---------------------------------------------*/ /* Total the first MIN_DAYS-1 days to see if we*/ /* start in an up trend or a down trend. (We */ /* start in an up trend if the price on day */ /* MIN_DAYS is greater than the average price */ /* during the first MIN_DAYS-1 days). */ /*---------------------------------------------*/ for ( lp = 1; lp <= MIN_DAYS - 1; lp++ ) initTotal += Data->Clse.value [lp]; /*---------------------------------------------*/ /* We want to capture the first trade. So if */ /* the market is up, we want to start long. */ /*---------------------------------------------*/ longPos = Data->Clse.value [MIN_DAYS] > ( initTotal / ( MIN_DAYS - 1 ) ); /*---------------------------------------------*/ /* We don't know what to use for the first SIP */ /* we'll just guess using the first day's data.*/ /*---------------------------------------------*/ if ( longPos ) nextSAR = Data->Low.value [1]; else nextSAR = Data->High.value [1]; /*---------------------------------------------*/ /* The SAR values are kept in the indicator */ /* storage array. We will init it to the next */ /* SAR too. */ /*---------------------------------------------*/ psDest->value [1] = nextSAR; ep = nextSAR; epYesterday = nextSAR; af = diff = af_x_diff = 0.0f; # ifdef SNINclc2_TRACE traceFile = fopen(TRACE_FILE_NAME, "wt"); fprintf(traceFile,"DAY --High- --Low-- --SAR-- ---EP--- --DIFF- --AF--- AF*DIFF\\n"); #endif /*---------------------------------------------*/ /* Loop through day 1, to the day before the */ /* last day (this is done because each pass */ /* thru this loop sets the following day's val.*/ /*---------------------------------------------*/ for ( lp = 1; lp < Data->Clse.LastValid; lp++ ) { # ifdef SNINclc2_TRACE fprintf(traceFile,"%3d %7.3f %7.3f %7.3f ", lp, Data->High.value[lp], Data->Low.value[lp], psDest->value[lp]); #endif /*---------------------------------------------*/ /* Column #2: Calculate the Extreme Price (EP).*/ /*---------------------------------------------*/ if ( longPos ) { ep = max(Data->High.value[lp], epYesterday); nextSAR = max(Data->High.value[lp], nextSAR); } /* if longPos */ else { ep = min(Data->Low.value[lp], epYesterday); nextSAR = min(Data->Low.value[lp], nextSAR); } /* else */ # ifdef SNINclc2_TRACE fprintf(traceFile," %7.3f", ep); #endif /*---------------------------------------------*/ /* Column #3: Calculate the difference between */ /* the SAR and the EP. */ /*---------------------------------------------*/ diff = (float)fabs( psDest->value [lp] - ep ); # ifdef SNINclc2_TRACE fprintf(traceFile," %7.3f", diff); #endif /*---------------------------------------------*/ /* Column #4: Calculate the acceleration factor*/ /*---------------------------------------------*/ if ( ep != epYesterday ) { if ( af + fStep < maximum ) { af += fStep; } /* if af */ else { af = maximum; } /* else */ } /* if ep */ # ifdef SNINclc2_TRACE fprintf(traceFile," %7.3f", af); #endif /*---------------------------------------------*/ /* Column #5: AF times the difference. (This */ /* doesn't really require an array for storage,*/ /* but it makes it easier to compare to with */ /* Wilder's book. */ /*---------------------------------------------*/ af_x_diff = (float)( af * diff ); # ifdef SNINclc2_TRACE fprintf(traceFile," %7.3f\\n", af_x_diff); #endif /*---------------------------------------------*/ /* Column #1: Calculate the next day's SAR. */ /*---------------------------------------------*/ if ( longPos ) { psDest->value [lp + 1] = psDest->value [lp] + af_x_diff; /*---------------------------------------------*/ /* Don't allow tomorrow's SAR to be above */ /* today's Low. */ /*---------------------------------------------*/ [/code:1:7a933bb5a3]
Patrick  
#16 Posted : Tuesday, August 16, 2005 8:59:00 PM(UTC)
Patrick

Rank: Advanced Member

Groups: Registered, Registered Users, Subscribers
Joined: 9/8/2004(UTC)
Posts: 2,266

Was thanked: 1 time(s) in 1 post(s)
Rest of the code: [code:1:4438b64d7f] psDest->value [lp + 1] = min(Data->Low.value[lp], psDest->value[lp+1]); /*---------------------------------------------*/ /* Don't allow tomorrow's SAR to be above */ /* yesterday's Low. */ /*---------------------------------------------*/ if ( lp > 1 ) psDest->value [lp + 1] = min(Data->Low.value[lp-1], psDest->value[lp+1]); } /* if longPos */ else { psDest->value [lp + 1] = psDest->value [lp] - af_x_diff; /*---------------------------------------------*/ /* Don't allow tomorrow's SAR to be below */ /* today's High. */ /*---------------------------------------------*/ psDest->value [lp + 1] = max(Data->High.value[lp], psDest->value[lp+1]); /*---------------------------------------------*/ /* Don't allow tomorrow's SAR to be below */ /* yesterday's High. */ /*---------------------------------------------*/ if ( lp > 1 ) psDest->value [lp + 1] = max(Data->High.value[lp-1], psDest->value[lp+1]); } /* else */ /*---------------------------------------------*/ /* See if we have changed position. */ /*---------------------------------------------*/ if ( ( ( longPos ) && ( psDest->value [lp + 1] > Data->Low.value [lp + 1] ) ) || ( ( !longPos ) && ( psDest->value [lp + 1] < Data->High.value [lp + 1] ) ) ) { # ifdef SNINclc2_TRACE fprintf(traceFile, "TRADE!\\n"); #endif if ( !firstValidTrade ) firstValidTrade = lp + 1; longPos = !longPos; af = 0.0f; psDest->value [lp + 1] = nextSAR; } /* if longPos */ /*---------------------------------------------*/ /* Save current EP in 'epYesterday' so we can */ /* see if it changes. */ /*---------------------------------------------*/ epYesterday = ep; } /* for lp */ # ifdef SNINclc2_TRACE fprintf(traceFile,"%c", FF); fclose(traceFile); #endif psDest->FirstValid = firstValidTrade; } /* if Data */ else { psDest->FirstValid = 1; psDest->LastValid = 0; } } /* function Calc_ParabolicSAR */[/code:1:4438b64d7f]
crwinnr5  
#17 Posted : Tuesday, August 16, 2005 10:13:53 PM(UTC)
crwinnr5

Rank: Advanced Member

Groups: Registered, Registered Users
Joined: 7/21/2005(UTC)
Posts: 74
Location: Oklahoma USA

Thank you Patrick, I do appreciate your help. Charley
Patrick  
#18 Posted : Tuesday, August 16, 2005 10:17:19 PM(UTC)
Patrick

Rank: Advanced Member

Groups: Registered, Registered Users, Subscribers
Joined: 9/8/2004(UTC)
Posts: 2,266

Was thanked: 1 time(s) in 1 post(s)
I will come back to this and spend more time on it later, sorry. I just have had a bad week :D I usually can finish stuff quickly but I have been having bad luck last week and everything suffered for it ... If you have questions or suggestions about the code let me know. Patrick :mrgreen:
pumrysh  
#19 Posted : Friday, August 19, 2005 5:46:26 PM(UTC)
pumrysh

Rank: Advanced Member

Groups: Registered, Registered Users, Subscribers
Joined: 10/28/2004(UTC)
Posts: 110

Patrick, From the looks of it I'd say your week has been pretty good. Curious though how you managed to stay up all night (past midnight my time)and then get up bright and early the next morning? It must be the brand of jo' you're using! For the record, I'm working on the code as well. Gotta love Wilders! Preston
Patrick  
#20 Posted : Friday, August 19, 2005 7:46:16 PM(UTC)
Patrick

Rank: Advanced Member

Groups: Registered, Registered Users, Subscribers
Joined: 9/8/2004(UTC)
Posts: 2,266

Was thanked: 1 time(s) in 1 post(s)
Well ... the secret is that I get Marilyn to bring me coffee every morning :D
Users browsing this topic
Guest (Hidden)
Similar Topics
Parabolic SAR Formula (Formula Assistance)
by Lorenzol 3/4/2006 11:19:13 AM(UTC)
Parabolic SAR formula (Formula Assistance)
by jacej 5/16/2005 4:16:10 AM(UTC)
2 Pages12>
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.