does anybody have a good piece of code that will retry the ordermodify X number of times w/ a pause in between each time if it doesn't work?
Thanks.
Thanks.
OrderModify - Error code 1 9 replies
BreakEven code keep calling OrderModify() 3 replies
Need help with OrderModify code 4 replies
OrderModify() problem (NOT error code 1) 3 replies
looping problem 2 replies
Dislikeddoes anybody have a good piece of code that will retry the ordermodify X number of times w/ a pause in between each time if it doesn't work?
Thanks.Ignored
DislikedHay nondisclosure
if you turn around it may not feel good but it'll be better.Ignored
//+------------------------------------------------------------------+ int ModifyOrder(int ticket, double entry=-1, double SL=-1, double TP=-1, int wait=0, int attempts=1, datetime expiry=0, color arrow=CLR_NONE) { //+------------------------------------------------------------------+ // Pass the above parameters, check and handle errnum upon return // if (OrderStatus(ticket) == "N") return(4108); // Invalid ticket int errnum = 0; if (entry >= 0) entry = NormalizeDouble(entry,Digits); else entry = OrderOpenPrice(); if (SL >= 0) SL = NormalizeDouble(SL,Digits); else SL = OrderStopLoss(); if (TP >= 0) TP = NormalizeDouble(TP,Digits); else TP = OrderTakeProfit(); if (OrderStatus(ticket) != "P") expiry = 0; if (expiry < TimeCurrent()) expiry = 0; for (int j=attempts; j>0; j--) { OrderModify(ticket,entry,SL,TP,expiry,arrow); errnum = GetLastError(); if (errnum == 1) errnum = 0; // ignore error #1 = no modification if (errnum == 0) break; if (j==1) return(errnum); Sleep(1000*wait); // wait = number of seconds RefreshRates(); } return(0); } //+------------------------------------------------------------------+ string OrderStatus(int ticket) { //+------------------------------------------------------------------+ // Given a ticket number, returns the status of an order: // P=pending, O=open, C=closed, D=deleted, N=non-existent ticket, U=unknown bool exist = OrderSelect(ticket,SELECT_BY_TICKET); if (!exist) return("N"); // non-existent ticket datetime ctm = OrderCloseTime(); if (ctm == 0) { if (OrderType() == OP_BUY || OrderType() == OP_SELL) return("O"); // open else return("P"); // pending } else { if (OrderType() == OP_BUY || OrderType() == OP_SELL) return("C"); // closed (for profit or loss) else return("D"); // cancelled (deleted) } return("U"); // unknown }
Disliked[code]
//+------------------------------------------------------------------+
int ModifyOrder(int ticket, double entry=-1, double SL=-1, double TP=-1, int wait=0, int attempts=1, datetime expiry=0, color arrow=CLR_NONE)...Ignored