Does anyone have a template for Closing trade and opening trade in the opposite direction?

 

Let's say if an EA open a buy order, the market move in the wrong direction. I want the EA to close that order and open in the opposite direction.

Does anyone have a template for Closing trade and opening trade in the opposite direction?

 
Reason: