I need the following function to complete:
double GetMaxLotSize(int cmd, double sl, double risk_margin = 1.0, string symbol = NULL)
Arguments are:
- cmd: Command such as OP_BUY or OP_SELL.
- sl: Stop loss to calculate the lot size for.
- risk_margin: Account margin to risk (in %), e.g. Money = AccountBalance() / 100 * risk_margin (e.g. 1.0%)
- symbol: If NULL, means current.
The output:
- Maximum safe lot size value to use where given SL won't exceed the percentage of risk margin amount.
This should work similar as GetMaxStopLoss() which calculates the maximum SL for given lot size, but GetMaxLotSize should work other way round.
The code should be compatible with MQL4 and MQL5.