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

MQL5 Komut dosyaları Entegrasyon

İş tamamlandı

Tamamlanma süresi: 1 gün
Müşteri tarafından geri bildirim
Great work, thanks.

İş Gereklilikleri

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. 

Yanıtlandı

1
Geliştirici 1
Derecelendirme
(590)
Projeler
789
71%
Arabuluculuk
9
33% / 33%
Süresi dolmuş
22
3%
Serbest
Yayınlandı: 8 kod
2
Geliştirici 2
Derecelendirme
(119)
Projeler
127
41%
Arabuluculuk
3
33% / 67%
Süresi dolmuş
0
Serbest
3
Geliştirici 3
Derecelendirme
(97)
Projeler
121
25%
Arabuluculuk
5
20% / 60%
Süresi dolmuş
17
14%
Serbest
4
Geliştirici 4
Derecelendirme
(133)
Projeler
185
30%
Arabuluculuk
77
9% / 73%
Süresi dolmuş
77
42%
Serbest
5
Geliştirici 5
Derecelendirme
(39)
Projeler
81
38%
Arabuluculuk
1
0% / 0%
Süresi dolmuş
31
38%
Serbest

Proje bilgisi

Bütçe
15 - 20 USD
Son teslim tarihi
from 1 to 3 gün