With several calculation methods, the composite function allows you to create a variety of composites, indices or market breadth indicators. This is the forth part of a series that presents the different calculation methods available in the composite function of QuantShare. In the first, second and third posts, we have introduced six methods which are: "Count", "Sum", "Avg", "Max", "Min" and "Sdv". All these methods have something in common: they all create a unique time series that is the same for all symbols/stocks. The Rank and Percentile function are different from the other methods in that they do not really create composites or indices but rather use data or quotes from all your symbols and return a unique value for each one of them based on how a specific value for a particular stock compares to other values from other stocks for the same date. Rank and Percentile The Rank function calculates the symbol's rank based on the time series you provide. Note that the symbol's rank will vary from date to date. This means that a stock could be ranked number one on a particular date and then ranked two, three or any other rank on the next day. The Percentile function works as the Rank function. However, instead of providing ranks, the Percentile returns values that vary between 0% and 100%. A value of 100% is the equivalent of the rank number 1 and a value of 0% correspond to the worst rank a symbol or stock may have. Let us use an example to further explain the Rank and Percentile functions. Imagine, we want to rank S&P 500 stocks based on their daily volume. The trading software will read S&P 500 stock quotes and then compare the volume time series of these stocks for each trading day. If Google had the biggest volume on August 12, 2010, then Google rank will be equal to 1. If we had used the Percentile function then Google percentile value would be equal to 100%. In the improbable case where there is only one stock for a particular date, this stock will get a rank value of one. The stock that has the lowest volume value, for day Y, will get a rank value that is equal to the number of stocks (with quotes) for that day Y minus one. Example of Rank and Percentile functions uses Comp(perf(close, 1), "Rank") <= 5 The above trading rule returns the top 5 stocks that have the highest one-bar rate of return. Comp(volume, "Percentile") >= 90 This volume-based trading rule gets stocks that are in the top 10% of stocks with the highest volume value. Unlike the above Rank function which returns only 5 stocks, the current one returns 10% of all stocks included in the analysis. If you have included 5000 stocks in your trading system then this volume rule will return 500 stocks. We'll see advanced uses of this powerful composite function later.
|