http:\/\/www.amibroker.com\/kb\/2014\/09\/26\/closing-trades-in-delisted-symbols\/<\/a> 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).<\/p>In rotational test however we cannot use Sell<\/strong> 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.<\/p>EnableRotationalTrading<\/span>();
<\/span>bi <\/span>= <\/span>BarIndex<\/span>();
<\/span>lastbi <\/span>= <\/span>LastValue<\/span>( <\/span>bi <\/span>) - <\/span>Status<\/span>(<\/span>"BuyDelay"<\/span>);
<\/span>exitLastBar <\/span>= <\/span>bi <\/span>== <\/span>lastbi<\/span>;
<\/span>score <\/span>= <\/span>\/*our regular positionScore*\/<\/span>;
<\/span>PositionScore <\/span>= <\/span>IIf<\/span>( <\/span>exitLastBar <\/span>, <\/span>0<\/span>, <\/span>score <\/span>)<\/code>Note that we are adjusting the last bar index in case trade delays are set in the settings.<\/p>
As in the regular test, we can also use DelistingDate information if we have it imported into Symbol ->Information window.<\/p>EnableRotationalTrading<\/span>();
<\/span>exitLastBar <\/span>= <\/span>datetime<\/span>() >= <\/span>GetFnData<\/span>(<\/span>"DelistingDate"<\/span>);
<\/span>score <\/span>= <\/span>\/*our regular positionScore*\/<\/span>;
<\/span>PositionScore <\/span>= <\/span>IIf<\/span>( <\/span>exitLastBar <\/span>, <\/span>0<\/span>, <\/span>score <\/span>)<\/code>","protected":false},"excerpt":{"rendered":"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 […]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[39],"tags":[15,62,61],"_links":{"self":[{"href":"https:\/\/www.amibroker.com\/wordpress\/kb\/wp-json\/wp\/v2\/posts\/1178"}],"collection":[{"href":"https:\/\/www.amibroker.com\/wordpress\/kb\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.amibroker.com\/wordpress\/kb\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.amibroker.com\/wordpress\/kb\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.amibroker.com\/wordpress\/kb\/wp-json\/wp\/v2\/comments?post=1178"}],"version-history":[{"count":2,"href":"https:\/\/www.amibroker.com\/wordpress\/kb\/wp-json\/wp\/v2\/posts\/1178\/revisions"}],"predecessor-version":[{"id":1180,"href":"https:\/\/www.amibroker.com\/wordpress\/kb\/wp-json\/wp\/v2\/posts\/1178\/revisions\/1180"}],"wp:attachment":[{"href":"https:\/\/www.amibroker.com\/wordpress\/kb\/wp-json\/wp\/v2\/media?parent=1178"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.amibroker.com\/wordpress\/kb\/wp-json\/wp\/v2\/categories?post=1178"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.amibroker.com\/wordpress\/kb\/wp-json\/wp\/v2\/tags?post=1178"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}