Dear All:
My backtesting shows puzzling results when applying 'positionscore' to select which stocks should be traded tomorrow in case we have more signals than allowable open positions.
The code processes signals at the end of the day for entry at the open in the next morning:
Buy = Rule1 AND Rule2 AND Rule3;
BuyPrice = Open;
PositionScore = 100-RSI(3);
SetTradeDelays(1,0,0,0);
Each evening, we run explore to select which tickers should be traded tomorrow:
filter = Buy;
AddColumn(PositionScore,"PositionScore");
AddColumn(Close, "Close");
As an example, we ran “explore” on 2025-01-31 and received the following buy signals (the top 3 tickers, given 'maxpos = 3'):
So next morning, we bought these 3 tickers. The back test running the next trading day (2025-02-03) then correctly shows:
So far, so good. We now run “explore” to receive the buying signals for the next day, and get this:
We now expect to see exactly the same 3 tickers in tomorrow’s backtest. However, this is what we see as we run the backtest:
It should have bought WSM, SNX, and RL. But it bought SNX, RL and... JBL? JBL should not appear here!
But it gets more puzzling if we run the same code to backtest 2025-02-04 only:
It has now picked the correct tickers.
The implication for my trading is troublesome, as I would be unable to trade exactly what has been backtested.
Any ideas on how to solve this puzzle would be greatly appreciated!
Kind regards and thank you in advance.




