little hepl please with a code

 

Hi guy .. I need a little help please .

I wrote this code and it dose execute the 1st order but the code after that didn't execute .

can anyone help..

void OnTick()
  {
 if(ordestotal1_2(OP_BUY)>=1){
  
  if(ordestotal1_3(OP_BUY)==0){
  bool m=OrderSend(Symbol(),OP_BUY,lot1,Ask,3,Bid-StopLoss*pt,Bid+TakeProfit*pt,NULL,MagicN,0,clrBlue);  //this order executed.
  }
  }

for(i=0;i<total;i++)
     {
      OrderSelect(i,SELECT_BY_POS,MODE_TRADES);
      if(OrderSymbol()==Symbol() && OrderMagicNumber()==MagicN)
        {
         int type=OrderType();

         if(type == OP_BUY )       {OpenLongOrders=OpenLongOrders+1;}
         if(type == OP_SELL )      {OpenShortOrders=OpenShortOrders+1;}
         if(type == OP_BUYSTOP )   {PendLongs=PendLongs+1;}
         if(type == OP_SELLSTOP )  {PendShorts=PendShorts+1;}

         if(total==1 && OpenLongOrders==1 && OpenShortOrders==0 && PendLongs==0 && PendShorts==0)
           {
            sellstop1();   // not executed dose anyone know why ?
           }
 }

//---------
int ordestotal1_2(int type) 
{ 
int total_2=0; 
for(int b=0;b<OrdersTotal();b++){ 
if(OrderSelect(b,SELECT_BY_POS,MODE_TRADES))
if(OrderType()==type){ 
total_2++; 
} 
} 
return(total_2); 
} 
//-----------------------------------------------


   int ordestotal1_3(int type) 
{ 
int total_2=0; 
for(int b=0;b<OrdersTotal();b++){ 
if(OrderSelect(b,SELECT_BY_POS,MODE_TRADES))
if(OrderSymbol()==Symbol()&&MagicN==OrderMagicNumber()&&OrderType()==type){ 
total_2++; 
} 
} 
return(total_2); 
} 
 
  1. bool m=OrderSend(...
    Check your return codes for errors, report them and you would know why. Don't just silence the compiler, it is trying to help you.
              What are Function return values ? How do I use them ? - MQL4 and MetaTrader 4 - MQL4 programming forum
              Common Errors in MQL4 Programs and How to Avoid Them - MQL4 Articles
    Only those functions that return a value (e.g. iClose, MarketInfo, etc.) must you call ResetLastError before in order to check after.


  2. Mohamed Abdelwaged: the code after that didn't execute .
    Use the debugger or print out your variables, including _LastError and find out why.