Close all position at the end of backtest using rotational backtester

How can I close all position at the end of the backtest using rotational backtester ?

Thanks.

AFL Function Reference - ENABLEROTATIONALTRADING

the score of zero means no trade (exit the trade if there is already open position on given symbol)

if you scroll down a bit to PositionScore

you could test using this Status( "LastBarInRange" ) AFL Function Reference - STATUS
test for last or 1 before last depending on Trade delays and set score to 0 could work.

Thank you for the pointers. I was able to get it to work with this code snippet.

PositionScore = IIf(Ref(Status("LastBarInRange"), 1), scoreExitAll, IIf(Rotation,Score,scoreNoRotate));
1 Like