September 27, 2015
How to handle delisted symbols in rotational test
This Knowledge Base article: http://www.amibroker.com/kb/2014/09/26/closing-trades-in-delisted-symbols/ explains how to close trades in delisted symbols in regular backtest (to avoid holding delisted stocks in the trade list and have our max symbol limit impacted by those positions).
In rotational test however we cannot use Sell variable, because trades are driven by symbols’ ranking by PositionScore values. Therefore we would need to assign zero to PositionScore variable for the exit bars respectively – this will force exiting any positions held in given stock.
EnableRotationalTrading();
bi = BarIndex();
lastbi = LastValue( bi ) - Status("BuyDelay");
exitLastBar = bi == lastbi;
score = /*our regular positionScore*/;
PositionScore = IIf( exitLastBar , 0, score )
Note that we are adjusting the last bar index in case trade delays are set in the settings.
As in the regular test, we can also use DelistingDate information if we have it imported into Symbol ->Information window.
EnableRotationalTrading();
exitLastBar = datetime() >= GetFnData("DelistingDate");
score = /*our regular positionScore*/;
PositionScore = IIf( exitLastBar , 0, score )
Filed by Tomasz Janeczko at 10:59 am under General
Comments Off on How to handle delisted symbols in rotational test