Script required for calculating lot size and partially closing positions

MQL5 Script

Lavoro terminato

Tempo di esecuzione 7 giorni
Feedback del cliente
Excellent work Michael. Thank you for making my life so much easier. Excellent communication and fast delivery. This is a guy who actually understands your requirements and makes it all happen.
Feedback del dipendente
It was a pleasure working with you! Your clear communication, prompt responses, and friendly demeanor made the process smooth and enjoyable. Thank you, Roel! Looking forward to serving you again!

Specifiche

Hello Programmers, 

I'm looking for an MQL5 script (not EA). The requirements and conditions are listed below.

Please be so kind to have a look at it and let me know if it can be scripted?
If yes, i would like to receive a quote if you're available.

Many thanks in advance for your assistance and please let me know if you have any questions or require additional information.

/Roel


Requirements and conditions:

• There are multiple positions (buy and sell positions) on US30 all with 3% risk.

• When launched, the script should check which position is in profit.
• Only if the winning position is at least 3000 ticks in profit, it should execute. If not, it should terminate without performing any action. 

• If the winning position is in profit for at least 3000 ticks, it should
- close the position
- Take 75% of the profit of that closed position and calculate the appropriate lot size.
- Partially close the position (reducing its lot size with the lot size that was calculated) in the opposite direction (sell if a buy was closed and a buy if a sell was closed) that is furthest away from current price and is currently in drawdown. 

• IF the lot size reduction (partial close) of the position in drawdown based on the 75% profit of the winning position exceeds the remaining lot size, the position in drawdown can be closed completely.
It cannot be closed completely under any other circumstances.
The remaining lot size can be subtracted now (partial close) from the next position that is now furthest removed from current price. 

• Please keep in mind, the minimum lot size for US30 is 0.1 lots.

• The currency used for trading is EUR. Not USD. 


• The lot size calculation for partial close is

(75% of winning position divided by the Loss of losing position) multiply the outcome by the lot size of losing position

Example: 

winning position is 400€ in profit

Losing position is 10 lots and 500€ drawdown

((400€ * 0.75) / 500€) * 10 = 6 lots to close


Example. 

Winning position has generated 300€ profit. and is 3000 ticks in profit and can be closed by the script. 

The script should look for the position in opposite direction in drawdown (hedge) furthest away from current market price
This position has a lot size of 1 lot and is 100€ in drawdown.

Calculation: 

300€ multiplied by 0.75 = 225€
Divide 225€ by 100€ drawdown of the losing trade = 2.25
Multiply 2.25 with the lot size of the position in drawdown which is 1 lot = 2.25 lots
2.25 lots of the 1 lot need to be closed from the position that is in drawdown.

The script should reduce the lot size of this position with 2.25 lots, so basically this position can be closed completely and there are still 1.25 lots left available

The script should look for the new opposite position in drawdown (hedge) that now is furthest away from current market price
This position is 5 lots, so it should partially close this position with 1.25 lots
The lot size of this position is now 3.75 lots

Script should terminate. 


Con risposta

1
Sviluppatore 1
Valutazioni
(428)
Progetti
624
54%
Arbitraggio
30
53% / 23%
In ritardo
6
1%
Occupato
2
Sviluppatore 2
Valutazioni
(25)
Progetti
33
24%
Arbitraggio
3
33% / 33%
In ritardo
4
12%
Gratuito
3
Sviluppatore 3
Valutazioni
(194)
Progetti
241
34%
Arbitraggio
10
50% / 50%
In ritardo
8
3%
In elaborazione
Pubblicati: 1 articolo, 8 codici
4
Sviluppatore 4
Valutazioni
(209)
Progetti
281
46%
Arbitraggio
27
59% / 37%
In ritardo
36
13%
Gratuito
5
Sviluppatore 5
Valutazioni
(542)
Progetti
624
33%
Arbitraggio
39
36% / 49%
In ritardo
11
2%
Occupato
6
Sviluppatore 6
Valutazioni
(16)
Progetti
35
23%
Arbitraggio
4
0% / 50%
In ritardo
2
6%
In elaborazione
7
Sviluppatore 7
Valutazioni
(4)
Progetti
4
0%
Arbitraggio
2
0% / 100%
In ritardo
1
25%
Gratuito
8
Sviluppatore 8
Valutazioni
(307)
Progetti
551
35%
Arbitraggio
79
32% / 42%
In ritardo
199
36%
Caricato
9
Sviluppatore 9
Valutazioni
(45)
Progetti
46
24%
Arbitraggio
34
9% / 85%
In ritardo
10
22%
Gratuito
10
Sviluppatore 10
Valutazioni
(152)
Progetti
190
57%
Arbitraggio
10
80% / 0%
In ritardo
0
In elaborazione
Pubblicati: 1 codice
11
Sviluppatore 11
Valutazioni
(45)
Progetti
91
13%
Arbitraggio
34
26% / 59%
In ritardo
37
41%
Gratuito
12
Sviluppatore 12
Valutazioni
Progetti
1
0%
Arbitraggio
0
In ritardo
0
Gratuito
13
Sviluppatore 13
Valutazioni
(618)
Progetti
1428
59%
Arbitraggio
31
81% / 0%
In ritardo
10
1%
Gratuito
14
Sviluppatore 14
Valutazioni
(72)
Progetti
80
10%
Arbitraggio
38
8% / 58%
In ritardo
6
8%
Gratuito
15
Sviluppatore 15
Valutazioni
(270)
Progetti
552
49%
Arbitraggio
57
40% / 37%
In ritardo
228
41%
In elaborazione
16
Sviluppatore 16
Valutazioni
(73)
Progetti
83
64%
Arbitraggio
5
100% / 0%
In ritardo
9
11%
Gratuito

Informazioni sul progetto

Budget
50 - 200 USD
Scadenze
da 1 a 5 giorno(i)