Lot Size calculation

 

Dear  All,


each time it returns increment value , i want to open next order multiple 1.4 times of current open lot sizes , i tried this 

double lot_size_total_sell()
{
   double a=0;
   int total  = OrdersTotal();
      for (int cnt = total-1 ; cnt >=0 ; cnt--)
      {
         OrderSelect(cnt, SELECT_BY_POS);
         if(OrderSymbol()==Symbol())
         if(OrderMagicNumber()==MagicNumber)
         if(OrderType()==OP_SELL)
         {a+=OrderLots();}
      }
   return(a);        
}


 
Syed Shanif Ahmed: i want to open next order multiple 1.4 times of current open lot sizes , i tried this 

That routine does return current open anything. It returns the sum of all open sell lots.

 
William Roeder:

That routine does return current open anything. It returns the sum of all open sell lots.

If my 1st trade size ia .01 , and factor lot is 1.4 , next time it returns me some thing that a=a+orderlots*1.4 , however i want only Orderslots*1.4
 
Syed Shanif Ahmed:

Dear  All,


each time it returns increment value , i want to open next order multiple 1.4 times of current open lot sizes , i tried this 

try this example, not tested!

double FixedLot=0.1;
double lotexponent = 1.4;
//---
double newlot;

//---This is the lot exponent function you use in your OrderSend()
newlot=NormalizeDouble(Calclots() * MathPow(lotexponent,your orders counting here),2);

//---Lots function(fixed lots)
double Calclots()
  {
   return(MathMin(MathMax((MathRound(FixedLot/MarketInfo(Symbol(),MODE_LOTSTEP))*MarketInfo(Symbol(),MODE_LOTSTEP)),
                          MarketInfo(Symbol(),MODE_MINLOT)),MarketInfo(Symbol(),MODE_MAXLOT)));
  }