I am using a Indicator which is generating Buy and Sell signals, I am using this indicator on Nifty chart, when a buy signal generates then I want to Buy a CE ATM of Nifty, when sell signal generates then I want to close CE and buy PE, but when I am selecting exit when opposite signal generates then it is not closing current opened position but it is opening opposite position. I.e if a CE is bought after buy signal, before TP if sell signal generates then it is not closing CE but buying PE. How to close PE before buying CE and closing CE before buying PE?