r_a_u_l Posted February 1, 2012 Report Share Posted February 1, 2012 hi i have this code sequence: ////////////// if (NewOrdersPlacedS) { if (flagS == TRUE) { for (cnt = OrdersTotal() - 1; cnt >= 0; cnt--) { if (OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES)) { if (OrderSymbol() == Symbol() && OrderMagicNumber() == MagicNumberS) { if (OrderType() == OP_SELL) { ErrorS = OrderModify(OrderTicket(), AveragePriceS, OrderStopLoss(), PriceTargetS, 0, Red); if (ErrorS == -1) ShowERROR (ErrorS,0,0); NewOrdersPlacedS = FALSE; } } } } } } ///////////////// i want the code to do the following: -- if (ErrorS == -1) ShowERROR (ErrorS,0,0); -- try again every 5 seconds until order is modified can anyone guide me alter the code? best regards, raul Quote Link to comment Share on other sites More sharing options...
iwjw Posted February 1, 2012 Report Share Posted February 1, 2012 Could be something like this: ErrorS=-1; int err=0; while(ErrorS==-1) { ErrorS = OrderModify(OrderTicket(), AveragePriceS, OrderStopLoss(), PriceTargetS, 0, Red); err=GetLastError(); if (ErrorS == -1) { ShowERROR (ErrorS,0,0); if(err==130) break; Sleep(5000); } } I would propose that you change the datatype of ErrorS into boolean because Ordermodify returns true/false and that's a bit cleaner. Second I would look for error 130 (invalid stops) and break the loop....otherwise it could never come back if the error doesn't have something to do with the STOPLEVEL Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.