How to code so the ea close the order by an opposite signal.

 
im trying to make an ea i put all the conditions to open trade but im stuck idk how to code so the ea close the order by an opposite signal.
Reason: