No new order if existing trade open backtest

My Buy condition comes true. In next bar it again becomes true. However I donot want to open a new position while previous position exits. How can I do so while backtesting?

In Zerodha Pi the Buy Condition Follows by Sell Condition

when pi gives simultaneous buy signals without exiting already open position while backtesting. How to avoid that? Consider only buy and exit buy conditions are coded