Download MetaTrader 5

buy buy buy or sell sell sell

To add comments, please log in or register
pompei
9
pompei  
hi
very good , I need some help, my EA made ​​several orders followed buy buy buy or sell sell sell but just want to make a signal , the first of each order is possible .. ?
Francis Dogbe
9697
Francis Dogbe  
pompei:
????
Rodrigo Malacarne
Moderator
10706
Rodrigo Malacarne  
pompei:

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
  • www.mql5.com
I am currently experiencing some multiple order execution problem with my EA but only for a specific broker. - - Category: expert advisors and automated trading
Osama Shaban
1584
Osama Shaban  

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);
}
To add comments, please log in or register