I am watching Dave McLachlan's video series and I have a basic question regarding position sizing when creating these trading algorithms. If I create a MaxPositionSize of 20, and I backtest it against the S&P 500, how does the algorithm determine which stocks to buy? If 40 meet the criteria, or 15? How do the positions determine how to fill?
If the model is actually run and set to trade, again, how does it determine what issues to buy if more than 20 are acceptable to purchase based on the rules of the algorithm?