For a while now I have been trying to figure out how to backtest delisted securities in amibroker. The problem being that the backtester won't close out your open positions when the stock is de-listed and eventually you just end up in de-listed securities with your equity going nowhere.
Anyways i've finally found a solution and though I'd post it here as I searched everywehere for it and could not find anything.
The solution is as follows:
Buy = ............
AND BarIndex() < (LastValue(BarIndex())-1);
Sell = .............
OR BarIndex() == (LastValue(BarIndex())-1);