Unable to perform Intraday Squareoff in Amibroker

Hello,

I am trying to squareoff my positions by the day end (intraday) in Amibroker using below piece of code.

{
FirstTradeTime = 094500; // Earliest time to take a trade
LastTradeTime = 150000; // Latest time to take new trades
ExitAllPositionsTime = 152500; // Exit all trades

Buy = Buy AND (TimeNum() >= FirstTradeTime AND TimeNum() <= LastTradeTime);
Sell = Sell OR (TimeNum() >= ExitAllPositionsTime);

}

But my positions are still carried forward till the next day during the backtest. Please help. Thanks in advance !!
Capture

Regards,
Rahul Jain