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

MQL5 Scripts Intégration

Tâche terminée

Temps d'exécution 1 jour
Commentaires du client
Great work, thanks.

Spécifications

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. 

Répondu

1
Développeur 1
Évaluation
(590)
Projets
789
71%
Arbitrage
9
33% / 33%
En retard
22
3%
Gratuit
Publié : 8 codes
2
Développeur 2
Évaluation
(119)
Projets
127
41%
Arbitrage
3
33% / 67%
En retard
0
Gratuit
3
Développeur 3
Évaluation
(97)
Projets
121
25%
Arbitrage
5
20% / 60%
En retard
17
14%
Gratuit
4
Développeur 4
Évaluation
(133)
Projets
185
30%
Arbitrage
77
9% / 73%
En retard
77
42%
Gratuit
5
Développeur 5
Évaluation
(39)
Projets
81
38%
Arbitrage
1
0% / 0%
En retard
31
38%
Gratuit

Informations sur le projet

Budget
15 - 20 USD
Délais
de 1 à 3 jour(s)