Percent Rank code for Tradestation

Percent Rank code for Tradestation

{ 
Returns percent rank of the last price compared to the previous prices
Reproduces PercentRank function of the AmiBroker
}

Inputs:
	PriceArray[MaxSize](numericarray),
	Length(numeric);

Vars:
	count(0),
	index(0);
		
count = 0;
for index = 1 to Length begin
	if PriceArray[0] > PriceArray[index] then count = count + 1;
end;
PercentRankAB = 100 * count / Length;