Parabolic SAR code!

 

Hi, i need to make a code with the Parabolic SAR function (iSAR). This code have to make an action when the dots of the Parabolic change of direction.

Something like this:

//----

if Parabolic dot change direction

do something like buy or sell

//----

Thanks!

Bye!

 


Keep us informed of your progress.

 
phy:


Keep us informed of your progress.


i dont have any progress yet.

im confused about how to use the function iSAR.

Can anyone help me?

 

"im confused about how to use the function iSAR."

At what point do you become confused?

 

My code is like this:

sar1 = sar2; //these variables are statics
sar2 = iSAR(NULL, 0, 0.02, 0.2, 0);

if(sar1<Open[1] && sar2>Open[0]) //if the value of the previous SAR dot is lower than the open price of the previous bar AND the value of the current SAR dot is higher than the open price of the current bar
{
OrderSend("EURUSD", OP_SELL, 1, Bid, 3, Bid+30*Point, Bid-10*Point, 0, Red); //sell

}

if(sar1>Open[1] && sar2<Open[0]) //if the value of the previous SAR dot is higher than the open price of the previous bar AND the value of the current SAR dot is lower than the open price of the current bar
{
OrderSend("EURUSD", OP_BUY, 1, Ask, 3, Ask-30*Point, Ask+10*Point, 0, Blue); //buy

}

the problem is that the EA do the buy/sell operation in the second SAR dot.

 

try

sar1 = iSAR(NULL, 0, 0.02, 0.2, 1);

sar2 = iSAR(NULL, 0, 0.02, 0.2, 0);

 

with that lines the ea dont make the operation of buy/sell.

what´s the function of the last parameter or iSAR?

 
Last parameter "Calculate SAR for this bar"
 

Hey man i did it!

The problem wasnt the code, it was the strategy tester. I was working with the open price in the source and in the model of the strategy tester.

In demo account, it works great!

 

Why don't you upload it and share it with the world

:)

 

Hello juan

can you tell us if it is good strategy, did it work for you?

Reason: