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:
This is a detailed view on the day when exit was ignored on the entry candle:
There is sell signal and yet the position is not closed.
Any tip what I am doing wrong?