i know how to select last open order and it is possible like this:
OrderSelect(OrdersTotal()-1,SELECT_BY_POS); or OrderSelect(LastTicket,SELECT_BY_TICKET);
but the problem is: i have many pending orders and i can only get the last order information by its ticket
i want to get the order information when every one of them goes from Buystop to Buy
any one knows how it is possible, help please...
- OrderSelect(OrdersTotal()-1 means the EA is incompatible with every other, including itself on other charts and manual trading.
- OrderSelect(LastTicket means your EA will not handle a terminal restart, reboot, power failure, etc. assuming you're not using persistent storage.
for(int iPos = OrdersTotal()-1; iPos >= 0 ; iPos--) if ( OrderSelect(iPos, SELECT_BY_POS) // Only my orders w/ && OrderMagicNumber() == Magic.Number // my magic number && OrderSymbol() == chart.symbol // and my pair. ){ if (OrderType() == OP_BUY){ // order is open else{ // Still pending
thanks for your respond but the problem is not solved yet...
suppose we select the latest 1.buystop when it reaches the price, then we put a new 2.buystop and a 3.sellstop based on our first 1.buy and at this time the 3.sellstop gets 3.sell and does not hit its TP but the price will open the 2.buystop meanwhile 3.sell still is open, so the problem is we will get the 3.sell instead of 2.buy...
hope you get my problem because my english is not well ;-)
- Don't understand your problem because you haven't explained what you need only some senario and that your code (that you don't post) doesn't handle it.
- Why are you using limits/stops in a EA. They're useful for humans as you don't need to be watching the screen waiting for price to hit. Not necessary for EAs since it is always watching. Just wait for the price to hit one of your levels and open an order.
- If you just want to delete the sellStop when the buyStop opens and visa versa try:
int closeAllOp = -1; for(int iPos = OrdersTotal()-1; iPos >= 0 ; iPos--) if ( OrderSelect(iPos, SELECT_BY_POS) // Only my orders w/ && OrderMagicNumber() == Magic.Number // my magic number && OrderSymbol() == chart.symbol // and my pair. ){ int OT = OrderType(); if (OT == OP_BUY) closeAllOp = OP_SELLSTOP; if (OT == OP_SELL) closeAllOp = OP_BUYSTOP; } for(int iPos = OrdersTotal()-1; iPos >= 0 ; iPos--) if ( OrderSelect(iPos, SELECT_BY_POS) // Only my orders w/ && OrderMagicNumber() == Magic.Number // my magic number && OrderSymbol() == chart.symbol // and my pair. && OrderType() == closeAllOp ){ if (!OrderDelete( OrderTicket() ) Alert("OrderDelete failed: ", GetLastError()); }
- 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 know how to select last open order and it is possible like this:
OrderSelect(OrdersTotal()-1,SELECT_BY_POS); or OrderSelect(LastTicket,SELECT_BY_TICKET);
but the problem is: i have many pending orders and i can only get the last order information by its ticket
i want to get the order information when every one of them goes from Buystop to Buy
any one knows how it is possible, help please...