Hi, If you're asking for the prices of the 'X' cheapest stocks at each bar, then you can probably reuse some code that I posted a while back which was looking for the 'X' highest PositionScore regardless of any actual Buy signals.
For your scenario, substitute the desired percentile for MaxPositions in my code, and pass Close to persistScores function instead of PositionScore. Then, reverse the logic to keep the lower values rather than the higher values. You can ignore the custom backtester logic entirely. This was my first attempt ever at writing in AFL so be sure to hand verify the results. Also, it is very slow since it iterates over every bar for each symbol to do the sorting. But, I believe that it will do what you are asking for. Your desired information will end up in the ATC symbol ~Position25. http://finance.groups.yahoo.com/group/amibroker/message/114739 Mike --- In [email protected], "droskill" <[EMAIL PROTECTED]> wrote: > > Not sure if anyone has any ideas, but I'm trying to express the > following idea in AB: > > "To get around questions related to inflation we looked at the price > of the 25th cheapest stock in the S&P 500 (5th percentile). Since > 1972, when the price of the 25th cheapest stock is below $6 the market > has a GPA of 23%. When the price of the 25th cheapest stock is between > $6 and $16 the market has gained 5%. Finally, the S&P 500 has gained > 1% when the price of the 25th cheapest stock is above $16." > > So anyone have any thoughts as to how to implement this, I'm guessing, > using ATC? > > Obviously you'll have a survivorship bias when looking at the S&P over > time, but I can't figure out how to calculate the bottom 5th percentile. > > Thoughts appreciated! >
