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

Notification

Icon
Error

Options
Go to last post Go to first unread
Lorenzol  
#1 Posted : Saturday, March 4, 2006 11:19:13 AM(UTC)
Lorenzol

Rank: Newbie

Groups: Registered, Registered Users, Subscribers
Joined: 3/4/2006(UTC)
Posts: 2

Hello, I would like to make some chances to the parabolic SAR. The parabolic SAR have 3 parameter that could be chanched. Metastock fix the starting AF at 0.02 and allow you to vary only the AF increment and the AF maximum. I want to chance the starting AF. Now I was looking for the formula for making that chances. I didn´t find the formula in Metastock. I Think it is an inbuild Indikator (.dll). Did someone have the Formula Code of the Parabolic SAR. Thanks (Sory for my bad english) Luis
StorkBite  
#2 Posted : Saturday, March 4, 2006 6:03:17 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)
I'm not sure that I've ever seen a MSFL formula for SAR... I know it can be done as an MSX in C++. There is already some work published on this. Google it for more info.
Lorenzol  
#3 Posted : Sunday, March 5, 2006 8:33:33 AM(UTC)
Lorenzol

Rank: Newbie

Groups: Registered, Registered Users, Subscribers
Joined: 3/4/2006(UTC)
Posts: 2

g_stockman wrote:
I'm not sure that I've ever seen a MSFL formula for SAR... I know it can be done as an MSX in C++. There is already some work published on this. Google it for more info.
I try to google it but didn´t find anything. I found a lot of pages where people asking for the Metastock SAR Formula. There was no response on that questions. I´m not a programmer. Could you explane why it is so dificult to write the SAR as MSFL Formula. Thanks Luis
Patrick  
#4 Posted : Sunday, March 5, 2006 9:57:04 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)
Here is the metaquote code for Parabolic SAR ... Hope this helps [code:1:d6482b5d5f]//+------------------------------------------------------------------+ //| Parabolic.mq4 | //| Copyright © 2004, MetaQuotes Software Corp. | //| http://www.metaquotes.net/ | //+------------------------------------------------------------------+ #property copyright "Copyright © 2004, MetaQuotes Software Corp." #property link "http://www.metaquotes.net/" #property indicator_chart_window #property indicator_buffers 1 #property indicator_color1 Lime //---- input parameters extern double Step=0.02; extern double Maximum=0.2; //---- buffers double SarBuffer[]; //---- int save_lastreverse; bool save_dirlong; double save_start; double save_last_high; double save_last_low; double save_ep; double save_sar; //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int init() { //---- indicators IndicatorDigits(Digits); SetIndexStyle(0,DRAW_ARROW); SetIndexArrow(0,159); SetIndexBuffer(0,SarBuffer); //---- return(0); } //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ void SaveLastReverse(int last,int dir,double start,double low,double high,double ep,double sar) { save_lastreverse=last; save_dirlong=dir; save_start=start; save_last_low=low; save_last_high=high; save_ep=ep; save_sar=sar; } //+------------------------------------------------------------------+ //| Parabolic Sell And Reverse system | //+------------------------------------------------------------------+ int start() { static bool first=true; bool dirlong; double start,last_high,last_low; double ep,sar,price_low,price_high,price; int i,counted_bars=IndicatorCounted(); //---- if(Bars<3) return(0); //---- initial settings i=Bars-2; if(counted_bars==0 || first) { first=false; dirlong=true; start=Step; last_high=-10000000.0; last_low=10000000.0; while(i>0) { save_lastreverse=i; price_low=Low[i]; if(last_low>price_low) last_low=price_low; price_high=High[i]; if(last_high<price_high) last_high=price_high; if(price_high>High[i+1] && price_low>Low[i+1]) break; if(price_high<High[i+1] && price_low<Low[i+1]) { dirlong=false; break; } i--; } //---- initial zero int k=i; while(k<Bars) { SarBuffer[k]=0.0; k++; } //---- check further if(dirlong) { SarBuffer[i]=Low[i+1]; ep=High[i]; } else { SarBuffer[i]=High[i+1]; ep=Low[i]; } i--; } else { i=save_lastreverse+1; start=save_start; dirlong=save_dirlong; last_high=save_last_high; last_low=save_last_low; ep=save_ep; sar=save_sar; } //---- while(i>=0) { price_low=Low[i]; price_high=High[i]; //--- check for reverse if(dirlong && price_low<SarBuffer[i+1]) { SaveLastReverse(i,true,start,price_low,last_high,ep,sar); start=Step; dirlong=false; ep=price_low; last_low=price_low; SarBuffer[i]=last_high; i--; continue; } if(!dirlong && price_high>SarBuffer[i+1]) { SaveLastReverse(i,false,start,last_low,price_high,ep,sar); start=Step; dirlong=true; ep=price_high; last_high=price_high; SarBuffer[i]=last_low; i--; continue; } //--- price=SarBuffer[i+1]; sar=price+start*(ep-price); if(dirlong) { if(ep<price_high && (start+Step)<=Maximum) start+=Step; if(price_high<High[i+1] && i==Bars-2) sar=SarBuffer[i+1]; price=Low[i+1]; if(sar>price) sar=price; price=Low[i+2]; if(sar>price) sar=price; if(sar>price_low) { SaveLastReverse(i,true,start,price_low,last_high,ep,sar); start=Step; dirlong=false; ep=price_low; last_low=price_low; SarBuffer[i]=last_high; i--; continue; } if(ep<price_high) { last_high=price_high; ep=price_high; } } else { if(ep>price_low && (start+Step)<=Maximum) start+=Step; if(price_low<Low[i+1] && i==Bars-2) sar=SarBuffer[i+1]; price=High[i+1]; if(sar<price) sar=price; price=High[i+2]; if(sar<price) sar=price; if(sar<price_high) { SaveLastReverse(i,false,start,last_low,price_high,ep,sar); start=Step; dirlong=true; ep=price_high; last_high=price_high; SarBuffer[i]=last_low; i--; continue; } if(ep>price_low) { last_low=price_low; ep=price_low; } } SarBuffer[i]=sar; i--; } // sar=SarBuffer[0]; // price=iSAR(NULL,0,Step,Maximum,0); // if(sar!=price) Print("custom=",sar," SAR=",price," counted=",counted_bars); // if(sar==price) Print("custom=",sar," SAR=",price," counted=",counted_bars); //---- return(0); } //+------------------------------------------------------------------+[/code:1:d6482b5d5f]
mstt  
#5 Posted : Sunday, March 5, 2006 6:49:43 PM(UTC)
mstt

Rank: Advanced Member

Groups: Registered, Registered Users, Subscribers
Joined: 7/25/2005(UTC)
Posts: 1,042

Was thanked: 57 time(s) in 54 post(s)
Luis The reason that SAR is so difficult to write in MFL is that there are several "activities" that must be kept track of simultaneously. In effect these activities must all be created, stored and updated in one variable. This means using many PREV functions - I've estimated as many as 30. The decisions that must be made within the one varaible cannot be made sequentially (in a series of simpler variables) because they are all interrelated. Simultaneous decision-making is a breeze for many programming languages, but not MFL. In theory is is possible to create MFL code for SAR, but the usefulness of anything with more than about 5 PREVS is seriously compromised, and more than 10 would be utterly hopeless to try and use. Roy MetaStock Tips & Tools
StorkBite  
#6 Posted : Sunday, March 5, 2006 10:15:24 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)
Here are some more resources: http://tadoc.org/indicator/SAR.htm
Users browsing this topic
Guest (Hidden)
Similar Topics
Parabolic SAR formula (Formula Assistance)
by jacej 5/16/2005 4:16:10 AM(UTC)
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.