Ok, not a bug.
SetVar(@ShortInterest,(FRank("SI%Float", #All, #ASC, #ExclNA)))
Between(@ShortInterest, 5, 98) // Move to bottom to work
SetVar(@SIChg, (SI%Float - Max(SI%FloatPM,1)) / Max(SI%FloatPM,1))
SetVar(@RankSIChg, FRank("@SIChg", #All, #DESC, #ExclNA))
Between(@RankSIChg, 20, 90)
The FRank function on line 4 requires @SIChg to be defined for every stock in the universe, not just the subset that passed the filter. But line 2's Between check eliminates stocks before @SIChg is assigned on line 3, so those eliminated stocks never get a value. When FRank then tries to rank all stocks by @SIChg , it hits the unassigned stocks and errors out.
We have 4 solutions. Not all solutions are equivalent. Some filter the Ticker list twice, and others filter the Ticker list in sequence.
Solution 1: Pre-assign values to @SIChg
SetVar(@SIChg,NA) // Preload
SetVar(@ShortInterest,(FRank("SI%Float", #All, #ASC, #ExclNA)))
Between(@ShortInterest, 5, 98)
SetVar(@SIChg, (SI%Float - Max(SI%FloatPM,1)) / Max(SI%FloatPM,1))
SetVar(@RankSIChg, FRank("@SIChg", #All, #DESC, #ExclNA))
Between(@RankSIChg, 20, 90)
Solution 2: Move ShortInterest filtering after FRank()
SetVar(@ShortInterest,(FRank("SI%Float", #All, #ASC, #ExclNA)))
SetVar(@SIChg, (SI%Float - Max(SI%FloatPM,1)) / Max(SI%FloatPM,1))
SetVar(@RankSIChg, FRank("@SIChg", #All, #DESC, #ExclNA))
Between(@RankSIChg, 20, 90)
Between(@ShortInterest, 5, 98) // Here I am!
Solution 3: FRank() tickers that pass ShortInterest filter by using #Previous scope
SetVar(@ShortInterest,(FRank("SI%Float", #All, #ASC, #ExclNA)))
Between(@ShortInterest, 5, 98)
SetVar(@SIChg, (SI%Float - Max(SI%FloatPM,1)) / Max(SI%FloatPM,1))
SetVar(@RankSIChg, FRank("@SIChg", #Previous, #DESC, #ExclNA)) // Note use of #Previous to define scope
Between(@RankSIChg, 20, 90)
Solution 4: Don't pass a filtered list to FRank() by embedding the formula directly in FRank()
SetVar(@ShortInterest,(FRank("SI%Float", #All, #ASC, #ExclNA)))
Between(@ShortInterest, 5, 98)
SetVar(@RankSIChg, FRank("(SI%Float - Max(SI%FloatPM,1)) / Max(SI%FloatPM,1)", #All, #DESC, #ExclNA)) // Literal formula
Between(@RankSIChg, 20, 90)