return value of 'OrderSend' should be checked

 

Hello my friends,

Ive got a little problem with a part of my ea. 

 

if (a=0) {OrderSend(Symbol(),OP_BUY,Lots,Ask,3,Ask-(StopLoss*Point),Bid+(TakeProfit*Point),NULL,Blue); printf ("buy");}

if (a=1) {OrderSend(Symbol(),OP_SELL,Lots,Bid,3,Ask+(StopLoss*Point),Bid-(TakeProfit*Point),NULL,Red); printf ("sell");}

 

return value of 'OrderSend' should be checked

return value of 'OrderSend' should be checked

 

I tried nearly everything for a couple of hours and need help now.

And yes, ive already usd google and the search funcktion on this side. I guess im just blind for my own mistakes.

Please help me. Thanks in advance! 

 

 
OrderSend()

Returned value:

Returns number of the ticket assigned to the order by the trade server or -1 if it fails. To get additional error information, one has to call the GetLastError() function.

if (a=0) {ticket=OrderSend(Symbol(),OP_BUY,Lots,Ask,3,Ask-(StopLoss*Point),Bid+(TakeProfit*Point),NULL,Blue); printf ("buy");}

if (a=1) {ticket=OrderSend(Symbol(),OP_SELL,Lots,Bid,3,Ask+(StopLoss*Point),Bid-(TakeProfit*Point),NULL,Red); printf ("sell");}

it will solve the warning, but you should still check the value:

if(ticket<0)
  {
   // OrderSend error.
   Print("OrderSend failed with error #",GetLastError()); 
  }
 
Marco vd Heijden:

Returned value:

Returns number of the ticket assigned to the order by the trade server or -1 if it fails. To get additional error information, one has to call the GetLastError() function.

it will solve the warning, but you should still check the value:

Thanks alot for the fast reply. The error is gone. THANKS!
 
GlennTF:
Thanks alot for the fast reply. The error is gone. THANKS!

No problem but it's warning, so no error, error would not compile at all.

Good luck on your project.

Reason: