I am trying hard to write the code into my EA to exit on change in PSAR. I use something like this
if(OrderType()==OP_BUY)
{
if(iSAR(0,0,0.02,0.2,1)<Ask && iSAR(0,0,0.02,0.2,0)>Ask)
{
OrderClose(OrderTicket(),OrderLots(),Bid,3,Violet);
return(0);
}
It closes but upon a last candle before changing psar it does this ugly thing where it opens and closes numerous times (see image)
Could anybody write a simple example how to cleanly exit on a psar change?
if(OrderType()==OP_BUY)
{
if(iSAR(0,0,0.02,0.2,1)<Ask && iSAR(0,0,0.02,0.2,0)>Ask)
{
OrderClose(OrderTicket(),OrderLots(),Bid,3,Violet);
return(0);
}
It closes but upon a last candle before changing psar it does this ugly thing where it opens and closes numerous times (see image)
Could anybody write a simple example how to cleanly exit on a psar change?