"return value of 'OrderModify' should be checked"

 

Hi all, I'm getting this warning message, it's to do with this line:

OrderModify(OrderTicket(), OrderOpenPrice(), OrderStopLoss(), 0, OrderExpiration());

My EA is working fine, however, and the function returns a value of True.

Should I ignore the message? Or can I resolve it somehow?

 
rrsch: Hi all, I'm getting this warning message, it's to do with this line: My EA is working fine, however, and the function returns a value of True. Should I ignore the message? Or can I resolve it somehow?

You should never ignore warning messages. They are potential run-time issues.

Always check the return value and act accordingly to catch any possible errors.

 

Check your return codes, and report your errors (including market prices and your variables). Don't look at GLE/LE unless you have an error. Don't just silence the compiler (MT5 / MT4+strict), it is trying to help you.
          What are Function return values ? How do I use them ? - MQL4 programming forum (2012)
          Common Errors in MQL4 Programs and How to Avoid Them - MQL4 Articles (2014)

 
Fernando Carreiro #:

You should never ignore warning messages. They are potential run-time issues.

Always check the return value and act accordingly to catch any possible errors.

Thanks guys. Like I mentioned (maybe not clearly enough), OrderModify is returning a value of True. For the heck of it I printed _LastError, which gives me a value of 0.

I just tried

OrderModify(OrderTicket(), OrderOpenPrice(), OrderStopLoss(), OrderTakeProfit(), OrderExpiration());

which is obviously pulling all of the values from the already existing order, and I get the same result.

I'm not sure what else to troubleshoot.

 
rrsch #: Thanks guys. Like I mentioned (maybe not clearly enough), OrderModify is returning a value of True. For the heck of it I printed _LastError, which gives me a value of 0.

I just tried

which is obviously pulling all of the values from the already existing order, and I get the same result.

I'm not sure what else to troubleshoot.

It does not matter if you expect it to return true or not. You should ALWAYS check the return value and process the condition.

if( OrderModify(OrderTicket(), OrderOpenPrice(), OrderStopLoss(), OrderTakeProfit(), OrderExpiration() )  {
   // Success - do something about it
} else {
   // Failed - do something (like reporting the error code)
};
 
Good evening. 
Very personally, in the error messages I add some information about can help to find out where the problem is. 

Look over there. The name of the file, the function, and other things that can be added to easily.

 
Fernando Carreiro #:

It does not matter if you expect it to return true or not. You should ALWAYS check the return value and process the condition.

Oh, I was really confused, but I think I get it now.

The warning message was telling me not that something is wrong, but that it wants to see me checking the outcome of the function. Right?

That took a moment for me to connect the dots! 😂

Thanks!

 
Gerard Willia G J B M Dinh Sy #:
Good evening. 
Very personally, in the error messages I add some information about can help to find out where the problem is. 

Look over there. The name of the file, the function, and other things that can be added to easily.

I do have error handling in the EA, I just didn't realize it wanted me to add it here. Thanks!

 
Gerard Willia G J B M Dinh Sy #: Very personally, in the error messages I add some information about can help to find out where the problem is. Look over there. The name of the file, the function, and other things that can be added to easily. https://www.mql5.com/en/docs/constant_indices
That is irrelevant! The OP is asking about a compile warning/error, NOT a run-time error. The compiler already identifies the exact line and character position of the warning/error.
 
rrsch #: Oh, I was really confused, but I think I get it now. The warning message was telling me not that something is wrong, but that it wants to see me checking the outcome of the function. Right? That took a moment for me to connect the dots! 😂
Correct!
 
Fernando Carreiro #:
Correct!

Thanks! Takes me a moment sometimes.