Please HELP!! with this EA

 

This EA which I've been trying to modify to my trading style keeps opening double trades (one buy and one sell) on the same currency pair(s).

For the life of me I cannot figure out why or fix this EA to keep it from doing this. I only want one trade in one direction to be open at time.

Can anyone who is more experienced at programming please HELP me with this.

Thanks

Files:
 

Always opened 1 trade when I tried it, however if you get a situation where price > lowday + mediacalc and price < highday - mediacalc, then two trades would open.

 

You may be have to add this function somewhere in the code to check if the symbol() is exist or not !

bool ExistPositions() {

for (int i=0; i<OrdersTotal(); i++) {

if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) {

if (OrderSymbol()==Symbol() && OrderMagicNumber()==MAGIC) {

return(True);

}

}

}

return(false);

}

Reason: