This is what I use (account normal, leverage = 100, lots precision = 0.1):
PHP Code:
double GetLots()
{
double Lots, PipValue;
if(UseMM)
{
PipValue = MarketInfo(Symbol(),MODE_TICKVALUE);
Lots = AccountEquity() * Risk / (StopLoss * PipValue * 100);
Lots = MathMin(Lots, 100);
return(NormalizeDouble(Lots,1));
}
else return(1.0);
}