How to close these orders?
-
Hi, in the case of a grid of orders, when I put the number of trade = 6 would that if the price retrace at the previous level of the order (# 5) I would like to close the losing trade # 6 and only the two positive # 1 and # 2, this is an old project and I do not come out
Thanks in advance
https://fxdreema.com/shared/qdful4ATd
-
@ambrogio Use "for each trade" loop, and just modify the looping direction and "not more than n" setting.

-
Just curious. What looping direction should be used?
-
@roar thanks for the lighting, in fact I solved better with fewer blocks (or at least it works)

-
This loop within a loop is a very interesting feature, ambrogio. I don't fully understand how it works. If I guess it correctly, the first 'For each trade' block will find the newest open buy and then, the second 'For each trade' below will seach for the oldest two open buys?
If so, how can you link each pending orders with the exact previous buy? I can't see it now.
-
Putting a loop inside a loop is basically a multiplication.
If there are 100 open trades and 3 trades meet the loss condition, then 2 oldest trades are closed 3 times.
As a result, 3 loss trades and 3*2=6 old trades are closed, 91 trades will be left open. -
@roar You mean there's something wrong in my updated project?
-
@ambrogio No, actually I think it's just optimal
-
@roar ok, thank you!