PositionScore array is writable in FIRST phase of backtest. It is used to SORT signals based on score values, before CBT starts. Changing it later makes no sense, as it is already AFTER sorting.
It seems that building code to sort all possible trades within CBT then would be the only way to assign ranking values to new entry signals and existing positions if there are different conditions for a new entry and an existing position.
You seem to be trying to do ROTATIONAL mode with different exit rules for existing positions.
That is already available out-of-the-box from EnableRotationalTrading.
The exit rank for existing positions can be DIFFERENT than entry rank. This is done by "WorstRankHeld" and "MaxOpenPositions".
The "MaxOpenPositions" is the allowable rank for entries. But "WorstRankHeld" can be greater than that and existing position would not be exited unless it drops out of "WorstRankHeld".
Thanks for your attention and the killer program, Tomasz!
What I'm actually trying to accomplish is ranking on momentum using the same metric but treating new entries differently than existing holdings. I gave an example earlier but a simple one might be like this:
entry signal: RSI(2) below 20 in the last 15 bars AND MA(C,10) > MA(C, 30)
hold signal: MA(C,10) > MA(C, 30)
A "hold" in the example above is the condition required to continue to hold an existing position. So two different situations (entry, hold) but use Rotational Trading and the same momentum metric to score each.
I've read a lot and tinkered with various ideas so far but can't figure out how to get there.
In that case you don't need rotational at all. And you don't need CBT. Use plain and simple regularBacktest.
Buy = Sum ( RSI( 2 ) < 20, 15 ) == 15 /* RSI2 below 20 in last 15 bars */
AND MA( C, 10 ) > MA( C, 30 );
Sell = Cross( MA( C, 30 ), MA( C, 10 ) );
PositionScore = ..whatever you wish..
In regular mode PositionScore is only used for entries.
In regular mode it won't exit already opened position, no matter what PositionScore is, until you get Sell signal.