Total monetary risk piece of code

MQL4 Experts Scripts

Termos de Referência

* A function, which I could add to start() or ontick() of any EA that would give a Comment() which lists;

   - The total monetary risk of the account based on open positions

   - Should work with any pair, any broker, any number of digits

   - If even one position has no SL, the risk is unlimited.

   - If there are one or more positions, and all have a SL, then it should calculate the max risk based on number of lots/microlots etc. open given the stoploss values.

   - If certain positions offset each other in risk (for example, 0.10 lots up, 0.05 down on the same pair)

   - The calculation should be per-MT4-account, irrespective of what EA the code is attached to

   - The calculation should return a single result in USD$

Example:

Comment ("The maximum risk of the 4 current open positions (0.23 lots) is $403.44 USD, if all stoplosses were hit simultaneously.");

Where 4, 0.23 and 403.44 are variables.


There should also be an offset switch. Two examples for off/on of this switch:

USDJPY 0.10 long + 0.05 short. SL is set at $10 for first position, at $5 for second.

setting: offset=0: SL1 $10 + SL2 $5 = $15 risk (this maximum risk could only be triggered if price went up/down enough to hit both stoplosses)

setting: offset=1: SL1 $10 - $SL2 $5 (since there are two positions on the same pair) = $5 more realistic risk

Thanks

Respondido

1
Desenvolvedor 1
Classificação
(4)
Projetos
7
43%
Arbitragem
5
0% / 60%
Expirado
3
43%
Livre
Publicou: 1 código
2
Desenvolvedor 2
Classificação
(20)
Projetos
43
30%
Arbitragem
6
0% / 50%
Expirado
17
40%
Livre
Publicou: 1 código
3
Desenvolvedor 3
Classificação
(30)
Projetos
93
49%
Arbitragem
18
56% / 17%
Expirado
38
41%
Livre
4
Desenvolvedor 4
Classificação
(64)
Projetos
144
46%
Arbitragem
19
42% / 16%
Expirado
32
22%
Livre

Informações sobre o projeto

Orçamento