How to know if a cross is fresh or not?

 
Hello guys, i'm developing an EA that is based on Moving average, i'm having a problem, i would like only to buy when the price cross the MA from bellow, and only sell, when prices cross from above.

This i have done, the problem is that when order is closed or the TP is hitted the EA open another order. I would like to know how to not open new orders if the price has not fresh crosses the MA.

Can anybody help me? i've attached the EA i've developed
Files:
sma.mq4  10 kb