how i can close first trade when third trade opened
-
how i can close first trade when third trade opened?
-
You need to explain more about what when and why you want this to happen, there are many options to achieve this.
-
ticket=1 buy position opened
ticket=2 sell position opened
ticket=3 buy position opened
ticket=4 sell position opened
ticket=5 buy position opened
ticket=6 sell position opened
ticket=7 buy position opened
ticket=8 sell position openedwhen open 3,close 1
when open 4, close 2
when open 5,close 3
when open 6, close 4 -
Maybe you can use loop.
"For each position"
Loop direction: Oldest to newest
Not more than "n" trades: 1Then link it to a "Close positions" block.
Put the loop after your Buy and Sell block, then every time a position is opened it should theoretically close the oldest position.
And since you want it separate for buys and sells, you create 2 of these identical loops and connect one to Buy block and one to Sell block. Also filter each loop by type for Buys or Sells.
I hope this works for you.
-
Or use the for each trade, get the open time in seconds after 1970, then use this to close by time value.