calculating lots

 
//+------------------------------------------------------------------+
//| volume                                                           |
//+------------------------------------------------------------------+
double volume()
  {
   Lots=AccountInfoDouble(ACCOUNT_MARGIN_FREE)/8000;
   Lots=MathMin(15,MathMax(0.1,Lots));
   Lots=NormalizeDouble(Lots,2);
   return(Lots);

  }

 

 

I'm just trying to figure out what exactly is happening in the above code segment. 

Why is the free margin divided by 8000?

Is line two calculating the maximum amount of "0.1" lots to a maximum of 15?

Why is my lot size 0.1? 

 

 

It first calculates a percentage of ACCOUNT_MARGIN_FREE by dividing it with 8000.

Then it calculates min and max value to keep it between the bandwidth.

Then it normalizes to a 2 digit double and returns the result.

It's one of the ways to get to a dynamic lot size, if the account grows, lotsize is going to increase, and if it shrinks, lotsize will also lower.

Like an automatic gearbox.

 
Another thing I was wondering is how leverage is calculated. Is this something the EA does, or does the broker set the leverage? When I run a back-test my profit level stays the same no matter what I set the leverage to.
 
theDUDE:
Another thing I was wondering is how leverage is calculated. Is this something the EA does, or does the broker set the leverage? When I run a back-test my profit level stays the same no matter what I set the leverage to.

Leverage is set by the broker. You can eventually request them to change it.

See also here.

Reason: