Percent Rank
All functions · nseries package
PercentRank
func (s Series) PercentRank(val float64, n int) Series
PercentRank computes the percentile rank of a value within a rolling window of n bars. Returns a value between 0 and 1 indicating where the given value falls within the sorted window, or -1 if the value is outside the window’s range. Consistent with TradeStation’s PercentRank function.
The output is on a 0 to 1 scale, despite the name, and is -1 when val lies outside the window’s range. The warm-up reads 0, not NaN: bars 0 to n-2 are exactly 0, the first valid index is n-1 and the minimum length is n. 0 reads as the bottom of the window; trim (Window(-(n-1))) or mask (SetN(n-1, math.NaN())) the warm-up first.