Workaround?

I need help constructing a portfolio. I’m borrowing the rules from a screen, which is optimized by selecting stocks ranked #4 - #15. I do this as follows:

FOrder(“rank”,#All,#desc,#Previous)>=4 and FOrder(“rank”,#All,#desc,#Previous)<=15

I get an error message attempting to use this rule in a Portfolio, the rule is not supported. Anyone know of a workaround so that the portfolio replicates the screen, i.e., avoids stocks ranked 1-3 and selects those ranked 4-15?

Thx,
Ed

Try using a variable, as in:

  1. setVar(@myVar, FOrder(“rank”,#All,#desc,#Previous))
  2. @myVar >= 4 AND @myVar <= 15

I still get this error message:

“Ranking function in Buy rule with #Previous parameter not supported at this moment”

I think #Previous cannot be used in Simulations or Portfolios.

Yes, exactly, that’s why I’m wondering if there’s a workaround in a Port. Seems to be a straightforward matter to be able to set parameters for the acceptable rank positions. Any other suggestions?

The structure of Sims is different from the Screener. When the screener was first created over 10 years ago it was similar to most other screens at the time. Only the stocks that pass a rule are passed on to the next rule. It tested all stocks against each rule in order, so #Previous would work. Much later ranking was added to the screener so it was easy to rank the final list of stocks that passed all the rules. If you are using a ranking system the rank order is evaluated on the stocks that passed all the rules.

In the Sims Ranking is done first, and all rules are evaluated to be true or false for each stock one stock at a time. It then saves or eliminates a stock only after is has been tested by all the rules. It then moves on to test the next highest ranked stocks. #Previous doesn’t work because the first time through for the highest ranked stock the previous rule is either true or false for only 1 stock. If #Previous was allowed to work it would have only 1 stock or 0 stocks depending on if the highest ranked stock was true or false for the previous rules. That is why it would be very difficult to allow #Previous in Sims without a major re-write of the code.

Denny, yes I understand this. My interest is not in the limitations of the #previous rule - what am asking is why can’t we bypass #previous altogether? Simply add a rule that eliminates all stocks above or below a certain numerical ranking? Or even better, allow us to define the range of stocks based on their numerical ranking. In other words, it mimics the effect of the #previous rule. Am I missing something?

Ed