English

## What's the use of the 1st assignment?

 16 a2495432675 2016.09.11 11:20   `Thanks a lot for help````input double Lots           =0.1;   //at the ea start, enter the parameter 0.1 here //and then there is a "lot" in the block following, there are two assignments for"lot", then what's the 1st assignment for? double LotsOptimized()   {    double lot=Lots;   // the 1st    int    orders=OrdersHistoryTotal();     // history orders total    int    losses=0;                  // number of losses orders without a break //--- select lot size    lot=NormalizeDouble(AccountFreeMargin()*MaximumRisk/1000.0,1);  // the 2nd //--- calcuulate number of losses orders without a break    if(DecreaseFactor>0)      {       for(int i=orders-1;i>=0;i--)         {          if(OrderSelect(i,SELECT_BY_POS,MODE_HISTORY)==false)            {             Print("Error in history!");             break;            }          if(OrderSymbol()!=Symbol() || OrderType()>OP_SELL)             continue;          //---          if(OrderProfit()>0) break;          if(OrderProfit()<0) losses++;         }       if(losses>1)          lot=NormalizeDouble(lot-lot*losses/DecreaseFactor,1);      } //--- return lot size    if(lot<0.1) lot=0.1;    return(lot);   }```
 16 a2495432675 2016.09.11 11:28 #   It give the "Lots" we entered to lot first, and then give a value to lot again according to account free margin, the previous value is covered by it right? so is that necessary to enter a Lots at the EA start ?It's from the sample Moving Average EA in MT4 program.I took course of C programming...and back here again lol..
12992
WHRoeder 2016.09.11 18:14 #

1.  lot is not used between the 1st and 2nd. ```   double lot=Lots;   // the 1st    int    orders=OrdersHistoryTotal();     // history orders total    int    losses=0;                  // number of losses orders without a break //--- select lot size    lot=NormalizeDouble(AccountFreeMargin()*MaximumRisk/1000.0,1);  // the 2nd``` So remove it. And then check if Lots is used anywhere. ```   int    orders=OrdersHistoryTotal();     // history orders total    int    losses=0;                  // number of losses orders without a break //--- select lot size    double lot=NormalizeDouble(AccountFreeMargin()*MaximumRisk/1000.0,1);  // once```