How to close a specific position without closing the others
-
Hi, I need to close the first open position when there are a total of 3 positions open. But I don’t want this to happen every time just once. After that, I don’t want it to do the same thing again until all the positions are closed.
If I let it close the first position every time there are 3 open, it would ruin my system.
In conclusion, I want to close the very first position opened when the system starts, and once that happens, I want to be able to continue opening new positions without closing any more.
Thank you
-
Not sure I fully get the idea. Please confirm this is correct.
- The bot waits until 3 open trades are active at the same time.
- Then, as soon as the third one is open, the first one (the oldest one) is immediately closed.
- Some time later a new trade is open, so there 3 open trades again. Point 2 aboce is immediatelay applied.
Is that your system?
-
What you’re saying is correct up to point 2. I just want it to happen once, because if it keeps doing it every time there’s a third open position, it will always close the oldest one.
What I really want is for it to happen the first time it detects that there are 3 open positions. The first order is different from the second and third, and if I don’t close that first order, it affects my strategy. Once the first order is removed, I wouldn’t have any problem if it keeps opening more trades.
-
Ok. I undersatnd. But is that sequence happening again in the future? I mean, will this 3-trades-close-first scenario happen later during trading? Or never again?
-
Never again. When the first trade is opened and the third one is reached, the first one will be closed. From that point on, it will never do it again until all open trades are closed.
-
Then you can use this structure in the 'on trade' tab:
https://fxdreema.com/shared/ncpryqz9c
As soon as your 3 open trades scenario is met, the oldest one will be immediately closed and the structure itself will be blocked forever. You can restore it later by using a 'tunr block On' when necessary.
-
Perfect, I'm going to try it. Thanks for the help, you're very kind.
-
You're welcome.
-
Use the "Check Trade Count" block to verify the number of open trades. When you want to close the oldest trade, use the "Counter : Pass Once" block. You should also use "Reset counter" blok when entering the first trade.