I think you need to use some Variable to store the current states while the EA is working. The type of variable can be "int" or "string" if you wish, it's a personal choice.
Otherwise more "professional" would be to have an indicator to make those buy and sell signals.
By the way this is impossible situation:
0_1543597465544_acd0558e-7583-44fb-bd4a-e46b47c8a019-image.png
.. because blocks does not wait to pass. You may take a look at this example: https://fxdreema.com/demo/mt4-wait-crossovers But I don't think it will work well for your strategy.