How to Cancel a Pending Order if it doesnt get triggered on the next following bar
OrderSelect(CurrentTicket, SELECT_BY_TICKET,MODE_TRADES); datetime OrderOptime=OrderOpenTime(); datetime timeValuePerBar= Period() * 60; if(Time[0]>(OrderOptime+timeValuePerBar)&& (OrderType()==OP_BUYSTOP){ ClosePendingOrder(Symbol(),CurrentTicket) // user defined function }ok i have come up with this can RaptorUK or any one else kindly verify this code. im assuming that OrderOpenTime() and Time[0] returns the time in seconds
ok i have come up with this can RaptorUK or any one else kindly verify this code. im assuming that OrderOpenTime() and Time[0] returns the time in seconds
Your code looks OK but doesn't do exactly what you said in your first post . . . ".But if this pending order does not get triggered in the next following bar" you code will potentially close an order during the following bar.
You don't need a user defined function, just do this . . .
OrderDelete(CurrentTicket);
hi guys im trying to create a stratergy where given a set of conditions becomes true in the current bar. i place a pending order.But if this pending order does not get triggered in the next following bar i want to cancel the trade.at the moment im struggling to come up with a solution for deleting the trade if it does not get triggered in the following bar. can any one help me out here
thankz