Australian (ASX) Stock Market Forum

Reply to thread

[USER=82525]@TraderJimmy[/USER] I am guessing that it detects that the stock is no longer trading (delisted)


[ATTACH=full]107837[/ATTACH]


with Norgate data you do not need to do this (as shown below)



How do I exit a position in a backtest prior to a stock being delisted?


Assuming a trade delay of 1 bar, you need to have an "exit" signal on the second last bar to simulate exiting a delisted stock. This will cause AmiBroker to exit the position on the final day of trading. You also want to avoid entering any new positions during the final 2 days.


OnSecondLastBarOfDelistedSecurity = !IsNull(GetFnData("DelistingDate")) AND (BarIndex() == (LastValue(BarIndex()) -1) OR DateTime() >= GetFnData("DelistingDate") ) ;

OnLastTwoBarsOfDelistedSecurity = !IsNull(GetFnData("DelistingDate")) AND (BarIndex() >= (LastValue(BarIndex()) -1) OR DateTime() >= GetFnData("DelistingDate") );


Top