How to change a code to set up a start lots?

 
double getLots(double lt) 
  (
   double marginrequired = MarketInfo(Symbol(), MODE_MARGINREQUIRED);
   double freemargin = AccountFreeMargin();
   if(freemargin > (marginrequired * lt)) 
     {
    
       return(lt);
     } 
   double result = freemargin / marginrequired;
   result = MathFloor(result * 10) / 10;
   return(result);
  }

How to change this code to make a possibility to set up in parameters to change a starting lots size?
 
Slawomir Dziegielewski:
double getLots(double lt) 
  (
   double marginrequired = MarketInfo(Symbol(), MODE_MARGINREQUIRED);
   double freemargin = AccountFreeMargin();
   if(freemargin > (marginrequired * lt)) 
     {
    
       return(lt);
     } 
   double result = freemargin / marginrequired;
   result = MathFloor(result * 10) / 10;
   return(result);
  }

How to change this code to make a possibility to set up in parameters to change a starting lots size?
bool runonce=0;// Flag
sinput double startlots=0.01;// Starting Lotsize
//+------------------------------------------------------------------+

//+------------------------------------------------------------------+
double getLots(double lt)
  {
   if(runonce==0)
     {
      result = startlots;
      runonce=1;
      return(result);
     }
   else if(runonce==1)
     {
      double marginrequired=MarketInfo(Symbol(),MODE_MARGINREQUIRED);
      double freemargin=AccountFreeMargin();
      if(freemargin>(marginrequired*lt))
        {

         return(lt);
        }
      double result=freemargin/marginrequired;
      result=MathFloor(result*10)/10;
      return(result);
     }
  }
//+------------------------------------------------------------------+

I take it literally.

 
Marco vd Heijden:
I take it literally.

Thank you at start,

 

I get a error: 'startlots' - declaration without type

 
Slawomir Dziegielewski:

Thank you at start,

 

I get a error: 'startlots' - declaration without type

but when put double I get a error:

'result' - undeclared identifier

 
Slawomir Dziegielewski:

but when put double I get a error:

'result' - undeclared identifier

bool runonce=0;// Flag
sinput double startlots=0.01;// Starting Lotsize
//+------------------------------------------------------------------+

//+------------------------------------------------------------------+
double getLots(double lt)
  {
   if(runonce==0)
     {
      double result = startlots;
      runonce=1;
      return(result);
     }
   else if(runonce==1)
     {
      double marginrequired=MarketInfo(Symbol(),MODE_MARGINREQUIRED);
      double freemargin=AccountFreeMargin();
      if(freemargin>(marginrequired*lt))
        {

         return(lt);
        }
      double result=freemargin/marginrequired;
      result=MathFloor(result*10)/10;
      return(result);
     }
  }
//+------------------------------------------------------------------+
 

If you always want to use same lot size then do the following ...

input StartLots = 0.01;

 then, 

double getLots(double lt) 
  (
   double marginrequired = MarketInfo(Symbol(), MODE_MARGINREQUIRED);
   double freemargin = AccountFreeMargin();
   if(freemargin > (marginrequired * lt)) 
     {
    
       return(StartLots);
     } 
   double result = freemargin / marginrequired;
   result = MathFloor(result * 10) / 10;
   return(StartLots);
  }

 In this code, you always enforce the getLots( ) function to return same StartLots value !!!.

I believe it will work !. 

 
Osama Shaban:

If you always want to use same lot size then do the following ...

 then, 

 In this code, you always enforce the getLots( ) function to return same StartLots value !!!.

I believe it will work !. 

Yes it work fine! 

 

Great thank you guys!

Good Luck Guys! 

Reason: