"return value of 'OrderSend' should be checked"

To add comments, please log in or register
Lucas Tavares
189
Lucas Tavares  

Hello guys, I just Followed THIS TUTORIAL, and made everything as it should be, but this error appear :

What is missing?
Thanks.

Step-By-Step Guide to writing an Expert Advisor in MQL5 for Beginners
Step-By-Step Guide to writing an Expert Advisor in MQL5 for Beginners
  • www.mql5.com
This article is aimed at beginners who wish to learn how to write simple Expert Advisors in the new MQL5 language. We will begin first by defining what we want our EA (Expert advisor) to do, and then move on to how we want the EA to do it. 1. Trading Strategy It will monitor a particular indicator, and when a certain condition is met (or...
Mohamad Zulhairi Baba
15840
Mohamad Zulhairi Baba  
lucastav:

...but this error appear

It’s not an error. It’s a warning.
OrderSend “should” be check on boolean basis
Example:

bool ticket = OrderSend(...);
Marco vd Heijden
Moderator
8153
Marco vd Heijden  

You didn't check the return value of OrderSend()

Please see: https://www.mql5.com/en/docs/trading/ordersend

Documentation on MQL5: Trade Functions / OrderSend
Documentation on MQL5: Trade Functions / OrderSend
  • www.mql5.com
[in,out]  Pointer to a structure of MqlTradeResult type describing the result of trade operation in case of a successful completion (if true is returned). parameter are filled out correctly. If there are no errors, the server accepts the order for further processing. If the order is successfully accepted by the trade server, the OrderSend...
Lucas Tavares
189
Lucas Tavares  
Mohamad Zulhairi Baba:
It’s not an error. It’s a warning.
OrderSend “should” be check on boolean basis
Example:

bool ticket = OrderSend(...);
Thanks, but could you explain more?

I never programmed, i just got the ability to learn things fast, but sometimes i get stucked in some steps.

Marco vd Heijden
Moderator
8153
Marco vd Heijden  

It's all in the documentation.

Just click the link and you will find it.

OrderSend

The OrderSend() function is used for executing trade operations by sending requests to a trade server.

bool  OrderSend( 
   MqlTradeRequest&  request,      // query structure 
   MqlTradeResult&   result        // structure of the answer 
   );

Parameters

request

[in]  Pointer to a structure of MqlTradeRequest type describing the trade activity of the client.

result

[in,out]  Pointer to a structure of MqlTradeResult type describing the result of trade operation in case of a successful completion (if true is returned).

Return Value

In case of a successful basic check of structures (index checking) returns true. However, this is not a sign of successful execution of a trade operation. For a more detailed description of the function execution result, analyze the fields of result structure.

To add comments, please log in or register