Hi
I have a problem with EA. I have wrote a program in EA. This is work in 3 currencies. Now my problem is here When 3 order are open (for example : EURUSD, EURJPY & USDJPY) and I wanna to close one of them (for example : EURUSD) How can I select this order to close and what is the command?
Your help is appreciated.
Just use OrderClose after OrderSelect() with Symbol() and Magic() check.
Hi
I have a problem with EA. I have wrote a program in EA. This is work in 3 currencies. Now my problem is here When 3 order are open (for example : EURUSD, EURJPY & USDJPY) and I wanna to close one of them (for example : EURUSD) How can I select this order to close and what is the command?
Your help is appreciated.
Here you are:
int CloseOrders(int magicnr) { int total=OrdersTotal(); for (int cnt=total-1;cnt>=0;cnt--) { OrderSelect(cnt,SELECT_BY_POS,MODE_TRADES); if (OrderMagicNumber()==magicnr && OrderSymbol()=="EURUSD") { if (OrderType()==OP_BUY) OrderClose(OrderTicket(),OrderLots(),MarketInfo(OrderSymbol(),MODE_BID),1); if (OrderType()==OP_SELL) OrderClose(OrderTicket(),OrderLots(),MarketInfo(OrderSymbol(),MODE_ASK),1); } } return(0); }Cheers

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hi
I have a problem with EA. I have wrote a program in EA. This is work in 3 currencies. Now my problem is here When 3 order are open (for example : EURUSD, EURJPY & USDJPY) and I wanna to close one of them (for example : EURUSD) How can I select this order to close and what is the command?
Your help is appreciated.