Trabajo finalizado
Tarea técnica
Hello devs,
I need an EA that manages my open trades and has a panel to change the values of the rules.
The EA needs the following rules:
- every trade that goes 20% in profit needs its SL moved 50% towards entry.
- Every trade that goes 50% in profit needs its SL moved to 1% profit.
- Every trade that goes 60% in profit needs to partial close 50%.
Example:
I take a buy order on EURUSD at 1.2000 with a lot size of 10. I set SL at 1.9500 and TP at 1.3000. When the trade goes in profit and price touches 1.2200, SL needs to be moved to 1.9750. Why?
1.2200 is 20% in profit.
How?
1.3000 - 1.2000 = 0.1000
0.1000 * 0.2 + 1.2000 = 1.2200
Why SL to 1.9750?
1.2000 - 1.9500 = 0.05
0.05 * 0.5 + 1.9500 = 1.9750
Next the trade goes 50% in profit (price touches 1.2500). Now SL needs to go 1% in profit (SL to 1.2100).
After that, price touches 1.2600, this is 60% in profit. Now the trade has to be closed for 50%, so 10 * 0.5 = 5 lots.
In a sell order it would be exactly the same calculations.
I take a sell order on GBPUSD at 1.5000 with a lot size of 8. SL is at 1.5600 and TP at 1.4200.
When trade goes 20% in profit, aka price touches 1.4840.
(1.4200 - 1.5000) * 0.2 + 1.5000 = 1.4840
Now SL needs to go 50% towards entry, aka SL to 1.5300.
(1.5000 - 1.5600) * 0.5 + 1.5600 = 1.5300
And so on…
Formula to calculate price at a certain percentage in profit:
TP = Take Profit price
EN = Entry Price
P = percentage in profit
(TP - EN) * P + EN = Price
Formula to calculate price at half SL:
SL = Stop Loss Price
EN = Entry price
(EN - SL) * 0.5 + SL = price
When I’ve manually entered a trade, the EA has to immediately calculate all the price points where a change is needed and save them. Now the EA only has to be in a while loop and check if a certain price is touched where a certain change is needed.
Every function in the code needs a description about what it does and its inputs and outputs. No DLLs
The EA may not open positions. It only may adjust manually entered trades.