Download MetaTrader 5

Open Only 1 Position

To add comments, please log in or register
Kerim Horoz
Kerim Horoz 2016.04.03 21:35 


I would like to open an order at 21:00 for instance, but it opens more than 1 position at that time because of more than one tick at that time. Would you help me out what I need to add on my codes ?



Osama Shaban
Osama Shaban 2016.04.04 10:20  

Add this function to check if there is an open order or not ...

bool ExistPositions(){
   for (int i=0; i<OrdersTotal(); i++) {
      if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) {
         if (OrderSymbol()==Symbol() && OrderMagicNumber()==MagicNo) {
Add ExistPositions() into your code logic where a new order will open ...  Like,
if(!ExistPositions() && a>b && ... && ...)

To add comments, please log in or register