Write a function to calculate maximum lot size for the given percentage margin of risk

MQL5 脚本 积分

工作已完成

执行时间1 一天
客户反馈
Great work, thanks.

指定

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. 

反馈

1
开发者 1
等级
(590)
项目
789
71%
仲裁
9
33% / 33%
逾期
22
3%
空闲
发布者: 8 代码
2
开发者 2
等级
(119)
项目
127
41%
仲裁
3
33% / 67%
逾期
0
空闲
3
开发者 3
等级
(97)
项目
121
25%
仲裁
5
20% / 60%
逾期
17
14%
空闲
4
开发者 4
等级
(133)
项目
185
30%
仲裁
77
9% / 73%
逾期
77
42%
空闲
5
开发者 5
等级
(39)
项目
81
38%
仲裁
1
0% / 0%
逾期
31
38%
空闲

项目信息

预算
15 - 20 USD
截止日期
 1  3 天