MQL4 Simple Open Order Script

 
Just trying to place a buy market order. I am following this https://book.mql4.com/trading/ordersend documentation

input double   Lots=0.01;
input int      SL=500;

int start()                                  
  {                                         
   OrderSend(Symbol(),OP_BUY,Lots,Ask,3,Bid-2*SL,Bid+SL);
   return;                                  
  }

These are the errors I get.


return value of 'OrderSend' should be checked
'return' - function must return a value


The first one is a warning

The second is an error


Thanks


 
Maruf Talukdar:
Just trying to place a buy market order. I am following this https://book.mql4.com/trading/ordersend documentation

These are the errors I get.



The first one is a warning

The second is an error


Thanks


input double   Lots=0.01;
input int      SL=500;
input int     Magic=99243;


int start()                                  
  {                                         
t bool Sonuc=  OrderSend(Symbol(),OP_BUY,Lots,Ask,3,Bid-2*SL*Point,Bid+SL*Point,"My order",Magic,0,clrBlue);
   return;                                  
  }
  }
 

Mehmet Bastem:

input double   Lots=0.01;
input int      SL=500;
input int     Magic=99243;


int start()                                  
  {                                         
t bool Sonuc=  OrderSend(Symbol(),OP_BUY,Lots,Ask,3,Bid-2*SL*Point,Bid+SL*Point,"My order",Magic,0,clrBlue);
   return;                                  
  }
  }


That will not compile. I guess that the "t" is a typo.

OrderSend returns an int, not a bool.


   If the compiler issues a warning don't ignore it, fix it.

   OrderSend();

may give you the error that the return value of OrderSend should be checked. The minimum that should be done is to print the error if it fails

preferably also print the open price, TP, SL.

   int ticket=OrderSend(_Symbol,OP_BUY,0.1,Ask,20,0,0,NULL,12345,0,clrNONE);
   if(ticket==-1)
      {
      Print("OrderSend for Buy order failed with error code ",GetLastError());
      }
   return;   //should return a value.    
   return(0);
 
Thank you everyone but I still get the same error although the warning is now gone. I have tried both reccomandations above. 
 
Maruf Talukdar:
Thank you everyone but I still get the same error although the warning is now gone. I have tried both reccomandations above. 

If you are still getting the same error then you did not pay attention to my post.

Reason: