Percentile

Statistical functions 
SYNTAX  Percentile( array, period, rank ) 
RETURNS  ARRAY 
FUNCTION  The Percentile function gives rank percentile value of the array over last period bars.
rank is 0..100  defines percentile rank in the array Performance note: the implementation of percentile function involves sorting that is relatively slow process even though that quicksort algorithm is used. Since version 5.92 Percentile supports variable period. Note that Percentile is very computation intensive function (it involves resorting arrays every bar) and variableperiod version (if you call it with period being ARRAY) runs slower than scalar version 
EXAMPLE  // Example 1:

SEE ALSO  Median() function 
The Percentile function is used in the following formulas in AFL online library:
See updated/extended version online.