Script required for calculating lot size and partially closing positions

MQL5 스크립트

작업 종료됨

실행 시간 7 일
고객의 피드백
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.
피고용인의 피드백
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!

명시

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. 


응답함

1
개발자 1
등급
(428)
프로젝트
624
54%
중재
30
53% / 23%
기한 초과
6
1%
바쁜
2
개발자 2
등급
(25)
프로젝트
33
24%
중재
3
33% / 33%
기한 초과
4
12%
무료
3
개발자 3
등급
(194)
프로젝트
241
34%
중재
10
50% / 50%
기한 초과
8
3%
작업중
게재됨: 1 기고글, 8 코드
4
개발자 4
등급
(209)
프로젝트
281
46%
중재
27
59% / 37%
기한 초과
36
13%
무료
5
개발자 5
등급
(542)
프로젝트
624
33%
중재
39
36% / 49%
기한 초과
11
2%
바쁜
6
개발자 6
등급
(16)
프로젝트
35
23%
중재
4
0% / 50%
기한 초과
2
6%
작업중
7
개발자 7
등급
(4)
프로젝트
4
0%
중재
2
0% / 100%
기한 초과
1
25%
무료
8
개발자 8
등급
(307)
프로젝트
551
35%
중재
79
32% / 42%
기한 초과
199
36%
로드됨
9
개발자 9
등급
(45)
프로젝트
46
24%
중재
34
9% / 85%
기한 초과
10
22%
무료
10
개발자 10
등급
(152)
프로젝트
190
57%
중재
10
80% / 0%
기한 초과
0
작업중
게재됨: 1 코드
11
개발자 11
등급
(45)
프로젝트
91
13%
중재
34
26% / 59%
기한 초과
37
41%
무료
12
개발자 12
등급
프로젝트
1
0%
중재
0
기한 초과
0
무료
13
개발자 13
등급
(618)
프로젝트
1428
59%
중재
31
81% / 0%
기한 초과
10
1%
무료
14
개발자 14
등급
(72)
프로젝트
80
10%
중재
38
8% / 58%
기한 초과
6
8%
무료
15
개발자 15
등급
(270)
프로젝트
552
49%
중재
57
40% / 37%
기한 초과
228
41%
작업중
16
개발자 16
등급
(73)
프로젝트
83
64%
중재
5
100% / 0%
기한 초과
9
11%
무료

프로젝트 정보

예산
50 - 200 USD
기한
에서 1  5 일