Oops, I made my example with TP for the pending order instead of SL. But anyway, what if SL of the Sell is also never reached by the price? You wrote "... until the stop loss is triggered...", but you can't be sure.
This is my example EA where I was testing this: https://fxdreema.com/shared/hTGdIdOA
But you know.. after all, having Buy and Sell with the same lot size is the more complicated version of simply closing the Buy trade. I don't recommend those "hedging" strategies. You can do all of this if it makes the EA easier to understand, but if you are doing it because you believe that this is protecting your capital... better don't 🙂 Your capital is what is written for "Equity", no matter if you have 0 or 10 opened trades. It's actually worse to have multiple trades opened (who hedge each other), because of spread, swap and so on.