Download MetaTrader 5

return value of 'OrderSend' should be checked

To add comments, please log in or register
Glenn Frackmann
1197
Glenn Frackmann  

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
5102
Marco vd Heijden  
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
1197
Glenn Frackmann  
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
5102
Marco vd Heijden  
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