Automation Position Reversal

i want to buy above 9.15 - 9.30 nifty candle. able to place buy order using range breakout but question is how to reverse the trade and close the previous buy position if breaks below of 9.15-9.30 candle

You can create two parallel branches of break above and break below. By using an IF condition which checks open positions from automation > 0, you can configure to place reverse orders in case the open positions > 0.