Download MetaTrader 5

return value of 'OrderSend' should be checked

To add comments, please log in or register
Copy the deals of successful traders. Subscribe to signals!
Glenn Frackmann
1245
Glenn Frackmann 2016.06.03 11:21 

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! 

 

Marco vd Heijden
Moderator
4707
Marco vd Heijden 2016.06.03 11:33  
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()); 
  }
Glenn Frackmann
1245
Glenn Frackmann 2016.06.03 11:41  
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!
Marco vd Heijden
Moderator
4707
Marco vd Heijden 2016.06.03 11:59  
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.

To add comments, please log in or register