Script required for calculating lot size and partially closing positions

MQL5 Komut dosyaları

İş tamamlandı

Tamamlanma süresi: 7 gün
Müşteri tarafından geri bildirim
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.
Geliştirici tarafından geri bildirim
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!

İş Gereklilikleri

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. 


Yanıtlandı

1
Geliştirici 1
Derecelendirme
(428)
Projeler
624
54%
Arabuluculuk
30
53% / 23%
Süresi dolmuş
6
1%
Meşgul
2
Geliştirici 2
Derecelendirme
(25)
Projeler
33
24%
Arabuluculuk
3
33% / 33%
Süresi dolmuş
4
12%
Serbest
3
Geliştirici 3
Derecelendirme
(194)
Projeler
241
34%
Arabuluculuk
10
50% / 50%
Süresi dolmuş
8
3%
Çalışıyor
Yayınlandı: 1 makale, 8 kod
4
Geliştirici 4
Derecelendirme
(209)
Projeler
281
46%
Arabuluculuk
27
59% / 37%
Süresi dolmuş
36
13%
Serbest
5
Geliştirici 5
Derecelendirme
(542)
Projeler
624
33%
Arabuluculuk
39
36% / 49%
Süresi dolmuş
11
2%
Meşgul
6
Geliştirici 6
Derecelendirme
(16)
Projeler
35
23%
Arabuluculuk
4
0% / 50%
Süresi dolmuş
2
6%
Çalışıyor
7
Geliştirici 7
Derecelendirme
(4)
Projeler
4
0%
Arabuluculuk
2
0% / 100%
Süresi dolmuş
1
25%
Serbest
8
Geliştirici 8
Derecelendirme
(307)
Projeler
551
35%
Arabuluculuk
79
32% / 42%
Süresi dolmuş
199
36%
Yüklendi
9
Geliştirici 9
Derecelendirme
(45)
Projeler
46
24%
Arabuluculuk
34
9% / 85%
Süresi dolmuş
10
22%
Serbest
10
Geliştirici 10
Derecelendirme
(152)
Projeler
190
57%
Arabuluculuk
10
80% / 0%
Süresi dolmuş
0
Çalışıyor
Yayınlandı: 1 kod
11
Geliştirici 11
Derecelendirme
(45)
Projeler
91
13%
Arabuluculuk
34
26% / 59%
Süresi dolmuş
37
41%
Serbest
12
Geliştirici 12
Derecelendirme
Projeler
1
0%
Arabuluculuk
0
Süresi dolmuş
0
Serbest
13
Geliştirici 13
Derecelendirme
(618)
Projeler
1428
59%
Arabuluculuk
31
81% / 0%
Süresi dolmuş
10
1%
Serbest
14
Geliştirici 14
Derecelendirme
(72)
Projeler
80
10%
Arabuluculuk
38
8% / 58%
Süresi dolmuş
6
8%
Serbest
15
Geliştirici 15
Derecelendirme
(270)
Projeler
552
49%
Arabuluculuk
57
40% / 37%
Süresi dolmuş
228
41%
Çalışıyor
16
Geliştirici 16
Derecelendirme
(73)
Projeler
83
64%
Arabuluculuk
5
100% / 0%
Süresi dolmuş
9
11%
Serbest

Proje bilgisi

Bütçe
50 - 200 USD
Son teslim tarihi
from 1 to 5 gün