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

MQL5 Script Integrazione

Lavoro terminato

Tempo di esecuzione 1 giorno
Feedback del cliente
Great work, thanks.

Specifiche

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. 

Con risposta

1
Sviluppatore 1
Valutazioni
(590)
Progetti
789
71%
Arbitraggio
9
33% / 33%
In ritardo
22
3%
Gratuito
Pubblicati: 8 codici
2
Sviluppatore 2
Valutazioni
(119)
Progetti
127
41%
Arbitraggio
3
33% / 67%
In ritardo
0
Gratuito
3
Sviluppatore 3
Valutazioni
(97)
Progetti
121
25%
Arbitraggio
5
20% / 60%
In ritardo
17
14%
Gratuito
4
Sviluppatore 4
Valutazioni
(133)
Progetti
185
30%
Arbitraggio
77
9% / 73%
In ritardo
77
42%
Gratuito
5
Sviluppatore 5
Valutazioni
(39)
Progetti
81
38%
Arbitraggio
1
0% / 0%
In ritardo
31
38%
Gratuito

Informazioni sul progetto

Budget
15 - 20 USD
Scadenze
da 1 a 3 giorno(i)