When I compile an EA that I try to develop I got this warning:
return value of 'OrderDelete' should be checked
this Error message came from this function:
Could any pro here help me to get rid from this warning.
You get this warning because you need to check the return value of the function when it's executed.
https://www.mql5.com/en/docs/standardlibrary/tradeclasses/ctrade/ctradeorderdelete
In your code, you can use this as an example.
int DeletePendingOrders(int Magic) int total = OrdersTotal(); for(int cnt = total - 1; cnt >= 0; cnt--) { if(OrderSelect(cnt,SELECT_BY_POS,MODE_TRADES)) if(OrderMagicNumber() == Magic && OrderSymbol()==Symbol() && (OrderType()==OP_BUYSTOP || OrderType()==OP_SELLSTOP || OrderType()==OP_BUYLIMIT|| OrderType()==OP_SELLLIMIT)) { if(OrderDelete(OrderTicket()) == false) { Alert("Your order is NOT deleted!"); } } }
- www.mql5.com
When I compile an EA that I try to develop I got this warning:
return value of 'OrderDelete' should be checked
this Error message came from this function:
Could any pro here help me to get rid from this warning.
OrderDelete return true if success or false if fail so you should check what is a result of executing OrderDelete e.g.:
if (!OrderDelete(OrderTicket())) Print("Order Delete Error "+IntegerToString(GetLastError()));
OrderDelete() returns a boolean (true/false). So the warning is telling you it should be checked to confirm if the function was successful. It won't stop your code compiling but you may experience unexpected results if you don't check the return value
eg:
bool res = OrderDelete(OrderTicket()); if (!res) { // Your OrderDelete failed here - what are you going to do? }
When I compile an EA that I try to develop I got this warning:
return value of 'OrderDelete' should be checked
this Error message came from this function:
Could any pro here help me to get rid from this warning.
You get this warning because you need to check the return value of the function when it's executed.
https://www.mql5.com/en/docs/standardlibrary/tradeclasses/ctrade/ctradeorderdelete
In your code, you can use this as an example.
You get this warning because you need to check the return value of the function when it's executed.
https://www.mql5.com/en/docs/standardlibrary/tradeclasses/ctrade/ctradeorderdelete
In your code, you can use this as an example.
I solved the problem with your aid my friends :)
Thanks a lot for every Pro who tried to help me here
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
When I compile an EA that I try to develop I got this warning:
return value of 'OrderDelete' should be checked
this Error message came from this function:
Could any pro here help me to get rid from this warning.