Close newest and oldest trade
-
Need same help. Suppose I had 10 opening position. I want to close the newest and the oldest position (no.1 and no.10) if profit of these two trades combine is achieved $ profit.
This Is what I created https://fxdreema.com/shared/wHKGD3xlc. Anyone advice, please!
-
@jimmy-chee said in Close newest and oldest trade:
Need same help. Suppose I had 10 opening position. I want to close the newest and the oldest position (no.1 and no.10) if profit of these two trades combine is achieved $ profit.
This Is what I created https://fxdreema.com/shared/wHKGD3xlc. Anyone advice, please!
can someone do something?
-
It's a bit odd to pick oldest and newest, but this should do:
https://fxdreema.com/shared/QRnvqa97 -
@roar thank you, but it closes them all, instead it should check the first trade (the one farthest then the less profitable) and as soon as there is one or more positive trades it must close only these positives and the first negative having a small profit
-
https://fxdreema.com/shared/fceTizc8
This one first calculates the amount of profitable trades. Then it checks the most losing trade against that profit sum, and if profit sum is bigger, close them all. Small losing trades will stay open. -
@roar Thank you.
-
@roar Instead of condition block, I replace by Formula Block. Thank a lot.
-
@roar please, where am I doing wrong?
-

The variables need to be reset at some point, otherwise the sum just piles up. Shared link somehow dropped that. I did that on the first loop block.
Tbh, I didn't actually do any test run with this ea, could still be faulty
-
@roar please, excuse my ignorance, your example closes an order after the other, I can not handle it


-
Mine works differently.

Here, take this .mq4 and import it to fxdreema so you get the exact same project. I also added a trade count condition for comfort.
0_1531746692796_hedge.mq4 -
@roar now it's running, strange is the same, thanks a lot!!
-
@roar what does this mean?

-
@ambrogio For changing a minus sign to a plus sign.
Lets assume the "profitSum", thats the sum of the positive profit trades, example $12
Then the profit of the losing trade can be -$57. Positive is always bigger than negative, so we have to -1 * -57 to make it +57 so we can better compare -
@roar oh clear thank you

-
Hi Roar and Ambrogio,
Attach the sample to close oldest and newest trade when reach certain profit shared/Gk6TueTcd. I use check profit (unrealized) or condition block to check profit from basket trade (all open position trade).
It is any way to check only the oldest and newest trade profit?The thing that already try been try as below:
a) Grouping – I only used one condition to entry the first trade and one condition to open additional trade. I think grouping is not the solution.
b) Variable and Formula – I can’t fine any block to read the profit from individual trade.
Any suggestion. -
-
-

If you set n=1, you can pick individual trades
-
This is what I created https://fxdreema.com/shared/Gk6TueTcd .
Trade close random.