Exit condition is sometimes ignored in very simple code

Hello,

I am testing this very simple code:

SetPositionSize(20, spsPercentOfEquity);  
SetOption("InitialEquity",25000);
SetOption("AllowSameBarExit",True);
SetOption("ActivateStopsImmediately",false);
SetOption("AllowPositionShrinking",False);
SetOption("FuturesMode",False);
SetOption("AccountMargin",100);
SetOption("maxopenpositions",5);
SetTradeDelays(0,0,0,0); 

Buy=				True;
BuyPrice=			O;

Sell=				C>O;
SellPrice = C;

Plot (Sell,"Sell",colorBlack);

Position should be closed when close is higher than open.

But when I run the backtest on for example stock NKTR - from 2/1/2018 to 2/28/2018 I can see that sometimes it closes the position at the end of day, some times not:

stats

This is a detailed view on the day when exit was ignored on the entry candle:

sell-ignored

There is sell signal and yet the position is not closed.

Any tip what I am doing wrong?
Thank you.

Its a portfolio backtest.
Check the various backtest modes and if that's having an effect on the signals.

https://www.amibroker.com/guide/afl/setbacktestmode.html

backtestRegular - regular, signal-based backtest, redundant signals are removed as shown in this picture

I have tried to add:

SetBacktestMode( backtestRegularRaw);

and also other backtest modes, but the result is always the same. Some days the trade is closed on the entry bar (if C>O), some not.

Eny other tip what can be wrong?