i have made the below codes to exit a strategy. however the strategy is not exiting even when conditions are met. the entry point of long is correct based on the entry conditions specified. however exit is not happening inspite of all 4 conditions being met screen shot of the same is also attached. pls advice as to how to rectify the same
if strategy.position_size > 0
if close[1] < sl
strategy.close (id="lx", qty=1, comment="sl")
if close <= hardstop
strategy.close (id="lx", qty=1, comment="hardstop")
if long_exit
strategy.close (id="lx", qty=1, comment="MA based exit")
if macd_long_exit
strategy.close(id="lx", qty = 1, comment="MACD reversal")
if strategy.position_size < 0
if close[1] > sl
strategy.close (id="sx", qty=1, comment="sl")
if close >= hardstop
strategy.close (id="sx", qty=1, comment="hardstop")
if short_exit
strategy.close (id="sx", qty=1, comment = "trail")
if macd_short_exit
strategy.close(id="sx", qty = 1, comment="MACD reversal")