This is something that you need to understand: https://fxdreema.com/demo/mt4-wrong-closing-rule (connecting everything in one row is not the answer)
I don't know why you use "For each Trade".
So, there are few ways to do this, it depends.
One way is to check the existance of the current orders/trades and create a new order based on that. Like, if there is a trade and there is no order -> create new order. The type of the last order or trade can be always get, everywhere and at any time.
Another way is to do it under "on Trade" and detect the exact moment when the old order becomes a trade. But this is an event that happens 1 time only and if the EA is not working at this moment, you will miss that event. You can actually prefer to do it that way.

