I feel like a dump this morning ...about takeovers.
Note my goal as a system trader is to simulate as close to actual trading as possible. Also, I’m not a short term trader.
There are two situations for takeovers, firstly holding a stock for a period then taken over (can’t avoid). Secondly, a buysignal is triggered by a takeover bid (can avoid).
This Amibroker code is relevant for both situations in backtesting delisted stocks. Trades that have been entered yet have no sell signal and these will "probably" have an exit value at or near takeover price.
Code:NonTradedPeriod = 30; SymbolDT = DateTimeAdd(DateTime(), NonTradedPeriod, inDaily); Delisted = BarIndex() == (LastValue(BarIndex()) -1) AND DateTimeDiff(Now(5), SymbolDT) >= 0; Sell = Sell or Delisted;
Better still, if you use Norgate data: https://norgatedata.com/amibroker-faq.php#exitpriortodelisting
If you don't use this for backtesting, you could be left with a bunch of stocks blocking buysignals. These stocks will withhold your capital and effect backtest results.
In real time trading, would you have exited on the announcement of a takeover, waited until the takeover is completed or accept a new ASX code?
I sell before a takeover is completed but should you choose to accept your mission of a new ASX code, what happens to exits? There would be no exitsignal for your new ASX code when running an Amibroker exploration as there would be no buysignal. Perhaps it's possible to manually add a trade but you could save the ASX code to favourites in Amibroker and check stops. Depending how complex exits are, this could be tricky. i.e. if your exit uses the buyprice or has some timed stop from the entry signal.
For the second situation where a takeover triggers a buysignal you could use one of the above choices (except “exited on the announcement”) but using the Amibroker code above simulates not buying, except if in real time the stock doesn’t end up being taken over!
Mr Monte Carlo is helpful guy
Unless I'm missing something I believe that the stale exit code used by @Skate addresses this problem.