Squaring off our position based on underlying spot price

You can do this in couple of different ways

Use basket order ATO - add exit orders in the basket and set the trigger at your preferred stop price.

Use TradingView webhooks to trigger basket or exit orders directly