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

MQL5 Sripts Integración

Trabajo finalizado

Plazo de ejecución 1 día
Comentario del Cliente
Great work, thanks.

Tarea técnica

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. 

Han respondido

1
Desarrollador 1
Evaluación
(590)
Proyectos
789
71%
Arbitraje
9
33% / 33%
Caducado
22
3%
Libre
Ha publicado: 8 ejemplos
2
Desarrollador 2
Evaluación
(119)
Proyectos
127
41%
Arbitraje
3
33% / 67%
Caducado
0
Libre
3
Desarrollador 3
Evaluación
(97)
Proyectos
121
25%
Arbitraje
5
20% / 60%
Caducado
17
14%
Libre
4
Desarrollador 4
Evaluación
(133)
Proyectos
185
30%
Arbitraje
77
9% / 73%
Caducado
77
42%
Libre
5
Desarrollador 5
Evaluación
(39)
Proyectos
81
38%
Arbitraje
1
0% / 0%
Caducado
31
38%
Libre

Información sobre el proyecto

Presupuesto
15 - 20 USD
Plazo límite de ejecución
de 1 a 3 día(s)