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

MQL5 Scripts Integração

Trabalho concluído

Tempo de execução 1 dia
Comentário do cliente
Great work, thanks.

Termos de Referência

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. 

Respondido

1
Desenvolvedor 1
Classificação
(590)
Projetos
789
71%
Arbitragem
9
33% / 33%
Expirado
22
3%
Livre
Publicou: 8 códigos
2
Desenvolvedor 2
Classificação
(119)
Projetos
127
41%
Arbitragem
3
33% / 67%
Expirado
0
Livre
3
Desenvolvedor 3
Classificação
(97)
Projetos
121
25%
Arbitragem
5
20% / 60%
Expirado
17
14%
Livre
4
Desenvolvedor 4
Classificação
(133)
Projetos
185
30%
Arbitragem
77
9% / 73%
Expirado
77
42%
Livre
5
Desenvolvedor 5
Classificação
(39)
Projetos
81
38%
Arbitragem
1
0% / 0%
Expirado
31
38%
Livre

Informações sobre o projeto

Orçamento
15 - 20 USD
Prazo
de 1 para 3 dias