Exiting bracket trade/order

Hey!

Im currently using alpaca with simple API market orders - my tradingview algorithm is using closing prices for entries and exits (and the algo has a stop loss, but it only triggers after the candle is closed).
Sometimes price falls fast and i’d need to set up a stop loss to Alpaca side to prevent some losses getting out of hand.

Once i set up the bracket BUY order it is buying and stop loss is in place, but when my algo sends a Market or Limit SELL signal (to take profit on specific price for example) - Alpaca will not exit my position.

So to keep this short: is there a simple order how to exit a bracket position?

you can probably use api.cancel_order() to cancel the pending portion of the bracket order.