Download MetaTrader 5
To add comments, please log in or register
Interested in MQL5 features? Find them in documentation!
18081961
678
18081961 2015.08.18 11:29 

Hi all,

Could you help me here,

 

Using the code I want to put to zero the counter if the condition fails.

Right now if; 

              if(BounceCount >= Bounce && Bid > BuyTrigger)

is true the ea puts the order and the counter is set to zero, but if it fails the ea do not put the order and the counter is not set to zero.

I appreciate any support from you and thank you in advance.

 

Luis Neves 

 

//Buy Order Condition to Open--------------------------------------------------------------------------------------------+
           
       if(Bid > BuyTrigger)      
        {
         BounceCount++;
        }
       if(BounceCount >= Bounce && Bid > BuyTrigger)
        {//5            
                 RefreshRates();                               
       BuyTicket = OrderSend(Symbol(),OP_BUY,LotSize,Ask,Slippage*pips2points,0,0,"Initial Buy Order",MagicNumber,0,Green);       
       if(BuyTicket > -1)     
        {//6
         PlaySound("alert.wav");
          Print(" Initial Buy Order Placed - BuyTicket: ",BuyTicket," Open Buy Price: ",DoubleToStr(OrderOpenPrice(),Digits)," Spread: ",DoubleToStr(Spread,Digits));                                                                                                
        }//6
      else
        {//7
        //GetLastError();
          BounceCount = 0;               
        }//7          
     return(0);
       }//5
Keith Watford
Moderator
8015
Keith Watford 2015.08.18 12:20  
luisneves:

Hi all,

Could you help me here,

 

Using the code I want to put to zero the counter if the condition fails.

Right now if; 

              if(BounceCount >= Bounce && Bid > BuyTrigger)

is true the ea puts the order and the counter is set to zero, but if it fails the ea do not put the order and the counter is not set to zero.

I appreciate any support from you and thank you in advance.

 

Luis Neves 

 

 

The counter is not set to zero when the order is placed, it is set to zero if the OrderSend() fails
/
To add comments, please log in or register