Hello pompei,
If you don't give more details about your problem, it will be very difficult to find any help for your problem.
Try to be more specific, and if possible try to show parts of your code, so you can get any help from users.
You can also try to take a look at this forum post: https://www.mql5.com/en/forum/23358
Regards,
Malacarne
![Multiple Order Entry Problem for live account with a specific broker Multiple Order Entry Problem for live account with a specific broker](/i/community/logo_mql5_small.png)
- www.mql5.com
You need to use a function to check existence of any open order before opening a new one ...
Follow these logical steps to let it go ...
Before opening any order, at the moment of the opening an order, the EA must check if there is no open orders of the same pair, if no order is opened, let it open that order, remember to use (return) to go to the starting point to prevent the program flow to continue checking other conditions.
Why use (return) ?
This solves a lot of problems like yours ... it will update the info to the EA that there is a new opened order to put it into consideration to prevent opening a new order.
I used to use the following function ...
bool ExistPositions() { for (int i=0; i<OrdersTotal(); i++) { if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) { if (OrderSymbol()==Symbol() && (OrderMagicNumber()==MagicUP || OrderMagicNumber()==MagicDN)) { return(True); } } } return(false); }
![MQL5 - Language of trade strategies built-in the MetaTrader 5 client terminal](https://c.mql5.com/i/registerlandings/logo-2.png)
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use