Script required for calculating lot size and partially closing positions

MQL5 Scripts

Tâche terminée

Temps d'exécution 7 jours
Commentaires du client
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.
Commentaires de l'employé
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!

Spécifications

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. 


Répondu

1
Développeur 1
Évaluation
(347)
Projets
471
51%
Arbitrage
22
50% / 27%
En retard
5
1%
Chargé
2
Développeur 2
Évaluation
(10)
Projets
16
13%
Arbitrage
1
0% / 100%
En retard
2
13%
Travail
3
Développeur 3
Évaluation
(166)
Projets
180
32%
Arbitrage
6
50% / 50%
En retard
2
1%
Travail
4
Développeur 4
Évaluation
(177)
Projets
237
45%
Arbitrage
17
82% / 12%
En retard
35
15%
Travail
5
Développeur 5
Évaluation
(469)
Projets
532
33%
Arbitrage
27
41% / 44%
En retard
8
2%
Chargé
6
Développeur 6
Évaluation
(10)
Projets
25
28%
Arbitrage
2
0% / 0%
En retard
1
4%
Chargé
7
Développeur 7
Évaluation
(4)
Projets
4
0%
Arbitrage
2
0% / 100%
En retard
1
25%
Gratuit
8
Développeur 8
Évaluation
(243)
Projets
431
34%
Arbitrage
55
36% / 38%
En retard
157
36%
Chargé
9
Développeur 9
Évaluation
(38)
Projets
40
25%
Arbitrage
23
13% / 70%
En retard
8
20%
Chargé
10
Développeur 10
Évaluation
(95)
Projets
117
38%
Arbitrage
9
89% / 0%
En retard
0
Gratuit
11
Développeur 11
Évaluation
(42)
Projets
88
14%
Arbitrage
30
30% / 57%
En retard
36
41%
Travail
12
Développeur 12
Évaluation
Projets
1
0%
Arbitrage
0
En retard
0
Gratuit
13
Développeur 13
Évaluation
(549)
Projets
1332
59%
Arbitrage
28
82% / 0%
En retard
10
1%
Gratuit
14
Développeur 14
Évaluation
(71)
Projets
80
10%
Arbitrage
35
9% / 54%
En retard
6
8%
Travail
15
Développeur 15
Évaluation
(266)
Projets
540
50%
Arbitrage
55
40% / 36%
En retard
224
41%
Gratuit
16
Développeur 16
Évaluation
(66)
Projets
71
63%
Arbitrage
4
75% / 0%
En retard
7
10%
Travail
Commandes similaires
Hi, I have a Compiled JForex strategy (.jfx file) I would like someone to convert it in to readable source code. Please let me know if you can do this task. Thank you
I want to make something automatic which EMA will automatically trade in my account. For this I want to make a simple robot I want to get this made automatically on a simple EMA
I need a professional who have the full knowledge in Ctrader and I want to add new idea for my ctrader https://ctrader.com/algos/indicators/show/3444/ Let me know if this is what you can do and the price to get it done. Thanks
I am looking for a skilled Thinkorswim script developer for a one-time project. Your task will be to combine 8 distinct Thinkorswim studies (I will provide the code for each) into one Lower Study. The final script should display histogram rows for the individual studies with a bubble color scheme of bright green, dark green, gray, dark red, and bright red
I need some who can develop my strategy and hand me over the source code... I will give you the specific area in the market i want to mark out and then set pending orders to execute once price move into the zone

Informations sur le projet

Budget
50 - 200 USD
TVA (21%): 10.5 - 42 USD
Total: 60.5 - 242 USD
Pour le développeur
45 - 180 USD
Délais
de 1 à 5 jour(s)