what's wrong with this code

To add comments, please log in or register
Ahmed Atef
18
Ahmed Atef  
excuse me whats wrong with this code >>
pending orders doesn''t work !!
 if(deff>0){
      double sum = (deff + b)/10;
      int h=(9-deff);
      double fin = (b-h)/10;
      
      ObjectCreate( 0  ,"8" , OBJ_HLINE , 0, 0 , fin  );
      ObjectCreate( 0  ,"6" , OBJ_HLINE , 0, 0 , sum  );
  
     
      if(OrdersTotal()==0){int res=OrderSend(Symbol(),OP_BUYLIMIT,0.1,(fin),3,sl,tp,NULL,Magicnumber,0,clrGreen);
        int sellticket = OrderSend(
    
                   Symbol(),         // currency pair on the chart
                   OP_SELLLIMIT,     // SELL LIMIT 
                   0.1,             // 10 Microlot
                   (sum),  // 20 points above the ask price
                   3,                // allow only 3 pips deviation
                   sl,                                  // No Stop Loss
                   tp,    // Take Profit 10 points
                   NULL,             // no comment
                   Magicnumber,                // no ID number
                   0,                // no expiration date
                   clrRed             // show green arrow
                  ); 
      
      }
     
      {
  if(deff<0){
      double sum1 = (deff + b)/10;
      int h1=(deff+9);
      double fin1 = (b+h1)/10;
      
      ObjectCreate( 0  ,"7" , OBJ_HLINE , 0, 0 , sum1  );
      ObjectCreate( 0  ,"5" , OBJ_HLINE , 0, 0 , fin1  );
      if (OrdersTotal()==0){
      int ticket1=OrderSend(Symbol(),OP_BUYLIMIT,0.1,sum1,3,sl,tp,NULL,Magicnumber,0,clrGreen);
      int sellticket1 = OrderSend
           (
             Symbol(),         // currency pair on the chart
                   OP_SELLLIMIT,     // SELL LIMIT 
                   0.1,             // 10 Microlot
                   (fin1),  // 20 points above the ask price
                   3,                // allow only 3 pips deviation
                   sl,                                  // No Stop Loss
                   tp,    // Take Profit 10 points
                   NULL,             // no comment
                   Magicnumber,                // no ID number
                   0,                // no expiration date
                   Red             // show green arrow
                  );     
          }   
      }
      }
    

}
Carl Schreiber
Moderator
8882
Carl Schreiber  
Ahmed Atef:
excuse me whats wrong with this code >>
pending orders doesn''t work !!

doesn't work?? My crystal ball has got a crack :(

Have you checked the logs? What do they say?

William Roeder
20251
William Roeder  
  1. "Doesn't work" is meaningless - just like saying the car doesn't work. Doesn't start, won't go in gear, no electrical, missing the key, flat tires - meaningless. There are no mind readers here and our crystal balls are cracked.

  2. 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.

  3. Use the debugger or print out your variables, including _LastError and find out why.
Guufuj Forex
147
Guufuj Forex  
Ahmed Atef:
excuse me whats wrong with this code >>
pending orders doesn''t work !!
Send the full code, lets see
To add comments, please log in or register