Bouncing Prices

 

Hi, I´m working on a hedging ea. I´m stuck on a transcendental problem here. What to do when price bounces on the opening position of the hedge. This leaves the original position opened (the one the hedge is hedging for) and the hedge opened, reversing the roles until I take the loss. Can´t really amend it but I´m sure there are various ways to reduce the probability.

Appreciate your advice,