You're close, but you cannot use "continue" unless you are inside a loop.
What you really want to do is handle the error. At a minimum, dump the error code to the log.
if ( ! OrderModify( . . . ) ) { // Do something to handle the error Print("Error in OrderModify. Error code=",GetLastError()); }
Function OrderModify() returns a value depending on the outcome:
If the function succeeds, it returns true, otherwise false.
So you have to check this value to see if the call was successful or not.
The best way to illustrate what it means is like this:
bool result; result = OrderModify(orders[0].ticket, NormalizeDouble(Ask + TrailingDistanceOrder1*point, Digits), OrderStopLoss(), OrderTakeProfit(), OrderExpiration()); if(result == 1) { Print("Ordermodify successful"); } if(result == 0) { Print("Ordermodify UN-successful"); }
- docs.mql4.com
I am struggling with this little mq4 piece of code.
I get the following error
return value of 'OrderModify' should be checked ea3WayHedging_1-9.mq4 399 10
I tried the following
then I get this error
';' - 'continue' must be used within some loop only ea3WayHedging_1-9.mq4 399 172
any idea what I am doing wrong and how to correct it would be appreciated.
Franzel
double TrailingDistanceOrder1=300; bool ticket; for (int i = 0; i < OrdersTotal(); i++) { if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES)==false) break; ticket= OrderModify(OrderTicket(), NormalizeDouble(Ask + TrailingDistanceOrder1*Point, Digits), OrderStopLoss(), OrderTakeProfit(), OrderExpiration()); }
if( !OrderModify(orders[0].ticket, NormalizeDouble(Ask + TrailingDistanceOrder1*point, Digits), OrderStopLoss(), OrderTakeProfit(), OrderExpiration()) ) Print("Error in OrderModify. Error code=",GetLastError()); else Print("Order modified successfully.");
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
I am struggling with this little mq4 piece of code.
I get the following error
return value of 'OrderModify' should be checked ea3WayHedging_1-9.mq4 399 10
I tried the following
then I get this error
';' - 'continue' must be used within some loop only ea3WayHedging_1-9.mq4 399 172
any idea what I am doing wrong and how to correct it would be appreciated.
Franzel