Need assistance on EA(Parabolic SAR)

 

Hi

My mt4 programming skills are very limited 

I've manage to create a simple EA with a EA builder platform

The section that I can't seem to get right is to allow the Ea only to take a trade on any of the first 3 dots of the parabolic SAR if it goes on the 4th dot no trade will be allowed

How do I tell the EA to take only trades on  first 3 dots 

Do I use the step or shift section like below ?

Buy example of the parabolic star section of the EA

Thanking you in advance

if(Close[1] > iSAR(NULL, PERIOD_CURRENT, 0.02, 0.2, 0) //Candlestick Close > Parabolic SAR
   && Close[1] <= iSAR(NULL, PERIOD_CURRENT, 0.02, 0.2, 3) //Candlestick Close <= Parabolic SAR
 
Morne Van Der Westhuizen:

Hi

My mt4 programming skills are very limited 

I've manage to create a simple EA with a EA builder platform

The section that I can't seem to get right is to allow the Ea only to take a trade on any of the first 3 dots of the parabolic SAR if it goes on the 4th dot no trade will be allowed

How do I tell the EA to take only trades on  first 3 dots 

Do I use the step or shift section like below ?

Buy example of the parabolic star section of the EA

Thanking you in advance


When psar trend (dots) switches (from up to down or down to up ) you can easily set a trade,cant you

Why do you need to check the 3 first psar's dots.

 
paulselvan:


When psar trend (dots) switches (from up to down or down to up ) you can easily set a trade,cant you

Why do you need to check the 3 first psar's dots.


 The psar is part of my strategy . I have a few other indicator that needs confirmation before a trade can be taken

So if all the other indicators are confirmed and the psar is on any of the first 3 dots then take the trade

That's why I need to check if the psar is on any of the first 3 dots

 

>oldTime, newTime avoid to trade in every tick ( trade allowed only when  new psar dot is opened )

>function psarSwitch() checks where psar dots are situated in comparaison with prices

>tradeDirection checks if psar dot is in trend continuity or if it's newly switched direction

>otherIndicatorSignal depends on your other indicators signals

//global variables
datetime oldTime, newTime;
int checkingFirst3Dots = 4;
//---------------------------------------------------------+
int OnInit(){
   oldTime = Time[0];
   return(INIT_SUCCEEDED);
}
//---------------------------------------------------------+
void OnTick(){     
   
   // Here your other indicators signals.
   bool otherIndicatorSignal = FALSE; //Set it TRUE if they acknowledge.
   
   //psar is checked on only  new open bars.  
   newTime = Time[0];
   if (oldTime != newTime){ 
       oldTime  = newTime; 
       //       
       double oldPsarDot = iSAR(_Symbol, _Period, 0.02, 0.2, 1);   
       double newPsarDot = iSAR(_Symbol, _Period, 0.02, 0.2, 0);      
       int tradeDirection = psarSwitch(newPsarDot, oldPsarDot);
       
       // is psar newly switched ?
       if (tradeDirection != -1) checkingFirst3Dots = 0;   
       //
       if (checkingFirst3Dots < 4) checkingFirst3Dots++;
       if ((otherIndicatorSignal == TRUE) && (checkingFirst3Dots != 4)) {            
         //Here check first if a trade is already opened.
         //If not your strategy allows to take a trade  
        
       }
   }
}
//---------------------------------------------------------+
int psarSwitch(double now, double old){
   /*this function returns :
   OP_BUY value if psar switches from down to up trend
   or OP_SELL value if psar switches from up to down trend
   or -1 in neither case*/
   
   int a = -1;
   if      ((Low[0] >= now) && (High[1] <= old))   a = OP_BUY;
   else if ((High[0] <= now) && (Low[1] >= old))   a = OP_SELL;
   return(a);
}

I hope its ok

 

@paul selvan

Please how can you make the parabolic sat buy or sell at the first candle only... I have been trying to do dat but it keeps on buying or sell till a new dot appears...

 
Please can anyone help me to create an EA to buy or sell at first candle only when a dot appears..??
Reason: