[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[amibroker] Re: Calculating the 25th percentile of the SP-500



PureBytes Links

Trading Reference Links

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 amibroker@xxxxxxxxxxxxxxx, "droskill" <droskill@xxx> 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!
>




------------------------------------

**** IMPORTANT ****
This group is for the discussion between users only.
This is *NOT* technical support channel.

*********************
TO GET TECHNICAL SUPPORT from AmiBroker please send an e-mail directly to 
SUPPORT {at} amibroker.com
*********************

For NEW RELEASE ANNOUNCEMENTS and other news always check DEVLOG:
http://www.amibroker.com/devlog/

For other support material please check also:
http://www.amibroker.com/support.html

*********************************
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/amibroker/

<*> Your email settings:
    Individual Email | Traditional

<*> To change settings online go to:
    http://groups.yahoo.com/group/amibroker/join
    (Yahoo! ID required)

<*> To change settings via email:
    mailto:amibroker-digest@xxxxxxxxxxxxxxx 
    mailto:amibroker-fullfeatured@xxxxxxxxxxxxxxx

<*> To unsubscribe from this group, send an email to:
    amibroker-unsubscribe@xxxxxxxxxxxxxxx

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/