Trabalho concluído
![](https://c.mql5.com/i/avatar/avatar_na2.png)
![](https://c.mql5.com/i/avatar/avatar_na2.png)
Termos de Referência
Kindly keep in mind this is a trade management EA so it compliments a manual trading strategy. That means not everything is disclosed below.
I need an EA that places pending hedging orders X pips away from the open position.
The EA should d the following.
Step 1: Every time a position is opened whether manually or automatically, the EA should immediately place an opposite trade pending order "x" pips away with double the lot size of the opened trade. Where X is a variable i should input when attaching the EA.
for example - assuming x is 10 pips - if I open a sell order with 0.2 lots. Immediately the EA should open a hedging buy stop pending order with 0.4 lots 10 pips away from the sell order.
Step 2:
The pending order placed will have a take profit 10 pips away.
example using EURUSD: open sell with 0.2 lots at 1.18000, ea places buy stop at 1.18100 with 0.4 lots. The buy stop order take profit is 1.18200.
kindly note that buy stop only has a take profit and no stop loss.
if th sell order hits Take profit is hit( not described how) then the pending order should be taken out immediately.
All pending orders should be closed immediately if TP is hit at any point
step 3:
The EA should as well modify the stop loss order of the original trade - in the case the sell order at 1.18000 - to to the Take profit price of the hedging trade.
so, the stop loss of the original trade is similar to the take profit price of the pending buy stop order. in our case at the 1.18200 price.
we will use the following terms:
NT is the latest trade to be activated, either opened manually or automatically. So in our example above, NT is the Sell order at 1.18000 with 0.2 lots.
HEDGING PENDING ORDER as HPO.
BUY STOP is BS
SELL STOP is SS
TAKE PROFIT is TP
STOP LOSS is SL
so in our example above:
NT = 1.18000/0.2
HPO = BS/1.18100/ 0.4 lots
HPO take profit = 1.18200
NT stop loss = 1.18200
step 4: very important - i call this the loop stage.
for this stage we will refer to the open trade - the sell order at 1.18000/0.2 lots - as NEWTRADE or NT
If the BS/1.18100/ 0.4 lots is activated, then that HPO becomes our new NT.
So, the EA opens new pending order as follows: - keep in mind the "X" is constant
NT = BS/1.18100/0.4
HPO = SS/1.18000/0.8
HPO take profit = 1.17900
Remeber perviously, the EA had not assigned BS/1.18100/ 0.4 lots a stop loss. So now the EA should modify the stop loss for BS/1.18100/ 0.4 lots to be the same price as HPO SS/1.18000/0.8 take profit price at 1.17900.
so, HPO SS/1.18000/0.8 take profit and HPO BS/1.18100/ 0.4 lots (which is now NT) stop loss = 1.17900.
if TP is hit, pending orders are deleted.
step 5: If If the HPOSS/1.18000/0.8 lots is activated, then that HPO becomes our new NT.
hence our NT becomes SS/1.18000/0.8
HPO = BS/1.18100/1.6
HPO take profit = 1.18200
remember, again the EA modifies the SL for SS/1.18000/0.8 to be the same price as HPO = BS/1.18100/1.6 take profit which is 1.18200.
so HPO = BS/1.18100/1.6 take profit and SS/1.18000/0.8 stop loss = 1.18200.
If TP hit, then all pending orders deleted.
step 6. If HPO BS/1.18100/1.6 is activated, then the EA opens HPO SS/1.18000/3.2 and we repeat the loop/ process untill TP is hit.
Finally:::
the EA should have a stop guard feature where it closes all LOSING open trades after i lose "X" percentage equity in all charts. Example, if I loose 10% of my total equity, it closes all open LOSING positions just leaving the profitable positions. It should give an option to choose my "X" % stop loss.
IT should also print on the screen a live calculation of the -ve% equity and the stop loss %