English

## Lot Size Calculator

 57 strontiumDog 2016.04.25 10:32   HelloFor a while I've been using the following lot size calculation in EAs, and more recently in a script I can drag onto a chart for it to do the lot size calc for manual trades automatically.  My trading partner said, 'wow and it handles situations where the base currency is GBP and the pair for calculation are for example AUDNZD where neither of the pair are the same as the base currency?'.  Now I'm suddenly in need of a sanity check that this is right.  I'm 99.9% sure it's OK other than the couple of points I've put in my own code, but I'd really appreciate someone on a higher plane than I reassuring me that I'm doing this right for all FX pairs (and would this work for Oil also?):```double ReturnLots(double _risk, double sl, double tickVal, double price) {     double minlot = MarketInfo(Symbol(), MODE_MINLOT);     double maxlot = MarketInfo(Symbol(), MODE_MAXLOT);     double leverage = AccountLeverage();     double lotsize = MarketInfo(Symbol(), MODE_LOTSIZE);     double stoplevel = MarketInfo(Symbol(), MODE_STOPLEVEL);         string cur = AccountInfoString(ACCOUNT_CURRENCY);         double bal = AccountInfoDouble(ACCOUNT_BALANCE); # just noticed I should be using equity not the available balance?         _risk = _risk / 100;         double numerator   = bal * _risk;         double denominator = sl  * tickVal;         if(numerator <= 0 || denominator <= 0) {             return(1); # just noticed this should be -1         } else {                 double result = numerator / denominator;                 if(result < minlot) {                         result = minlot;                 } else if(result > maxlot) {                         result = maxlot;                 }             return(result);         } } ```