Author: Copyright 2013, Mepkypuu.
Orders Execution
Checks for the total of open orders
0 Views
0 Downloads
0 Favorites
Get_Lots
//+------------------------------------------------------------------+
//|                                                     Get Lots.mq4 |
//|                                        Copyright 2013, Mepkypuu. |
//|                                                                  |
//+------------------------------------------------------------------+
#property copyright "Copyright 2013, Mepkypuu."
#property link      ""

double getLots(double newSL) {
   int opnTime = 0;
   double lotSum = 0; 
   for (int i = 0; i <= OrdersTotal()-1; i++) {
      OrderSelect(i, SELECT_BY_POS);     
      if ((OrderOpenTime() > opnTime) && (OrderType() == OP_BUY) || (OrderType() == OP_SELL)) { 
         opnTime = OrderOpenTime(); 
         if (OrderType() == OP_BUY)    { lotSum += OrderLots() * (newSL - OrderOpenPrice()) / Point; }
         if (OrderType() == OP_SELL)   { lotSum -= OrderLots() * (newSL - OrderOpenPrice()) / Point; }
      }
   }   
   return(lotSum);
}

Comments