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

Re: [amibroker] Re: Ranking of MG Industry Groups



PureBytes Links

Trading Reference Links

Bruce,

Thanks for the approach description.

Can't quite get my head around it right now ... I'll have to plow through 
the code ..

My data is normalized (percent) ROC, so your second approach, if I 
understand it correctly, may be more advantageous.

Ara

----- Original Message ----- 
From: "bruce1r" <brucer@xxxxxxxxx>
To: <amibroker@xxxxxxxxxxxxxxx>
Sent: Tuesday, June 26, 2007 9:49 AM
Subject: [amibroker] Re: Ranking of MG Industry Groups


> Ara -
>
> Maybe I can help a little on this one.  When I get some time maybe
> I'll write up a full routine, but the following should be enough to
> get you going.
>
> BOTTOM LINE - YOU DON'T NEED TO SORT IN ORDER TO RANK IF THE NUMBER OF
> THINGS TO RANK IS A SUBSET
>
> It is a common misconception that you do.  Let me offer a brief
> example to illustrate.
>
> Let's say that you have 50 arrays with one tick per day.  Each entry
> might be the relative strength of that ticker vs. an index.  So, you
> have different, unbounded numbers for each day for each of the 50 tickers.
>
> To find the rank of reference ticker #1 on any given day, I just need
> to compare it to the other 49 arrays and add 1 to each for each day
> that it is greater.  When I'm done, if ticker #1 is the top ranked, it
> will have 49 for that entry.  So, I subtract the array from the number
> of tickers (50) to get the rank.
>
> You have to do this for each reference ticker.  But, in most cases,
> you are only interested in the top few.  In this example, it might be
> the top (or bottom) 5 out of the 50.  If you have to do it for every
> reference ticker, it is still faster than other approaches because of
> the very fast array comparison operations in AB.  There is a way to
> cut those comparisons in half - but it is more involved and is another
> story for another day.
>
> I won't guarantee the following code, but it might look something like -
>
> symcount = 50;
> //  Let's say that you've read in the data via a Foreign() call to
> //  array1 through array50 and the reference array is array1
> refnum = 1;
> count = 0;
> refarray = varget( "array" + refnum );
> for ( i = 0; i < symcoung; i++ )
> {
>    count = IIf( refarray > varget( "array" + i ), count++, count )
> }
> rank = symcount - count;
> //  Rank is now the rank of the reference ticker on each day
> //  It is usually normalized to a percentage
> pcnt = 100 - ( rank - 1 ) / ( symcount - 1 );
>
>
>
> Hope this helps,
>
> -- Bruce R.
>
> P.S. The other major use of ranking is to normalize then combine
> unbounded indicators.  For example, say you wanted to rank a group of
> tickers based on weighted scores of relative strength, momentum, etc.
> You would just combine the weighted, (percentage) normalized scores.
>
> --- In amibroker@xxxxxxxxxxxxxxx, "Ara Kaloustian" <ara1@xxx> wrote:
>>
>> Here is a sort function that I got from the AB board,
>>
>> function sort(value)
>> {
>> //Value is array for same bar from all sectors
>> //12 data points (Sectors 2 through 13, based on Quotes Plus)
>> //
>> for(i = 13; i>=2; i--)
>> {
>>  for (j = 3; j <= i; j++)
>>  {
>>  if (value[j-1] > value[j])
>>   {
>>   tempvalue  = value[j-1];
>>   value[j-1] = value[j];
>>   value[j]   = tempvalue;
>>   }
>>  }
>> }
>> SortList = Value;
>> //list now sorted
>> //sortid = ID for top sector
>>
>> return SortList;
>> }
>>
>>
>> ----- Original Message ----- 
>> From: "marketmonk777" <RedEyes777@xxx>
>> To: <amibroker@xxxxxxxxxxxxxxx>
>> Sent: Monday, June 25, 2007 11:01 PM
>> Subject: [amibroker] Re: Ranking of MG Industry Groups
>>
>>
>> > --- In amibroker@xxxxxxxxxxxxxxx, "Gordon Sutherland" <gosuth@> wrote:
>> >>
>> >> Check-out the function:
>> >>
>> >> SetSortColumns( col1, col2, .... )
>> >>
>> >> Cheers,
>> >>
>> >> Gordon Sutherland
>> >
>> > Hi Gordon,
>> >
>> > That is a good solution for multi column sorting but I really am
>> > looking to rank each industry group based on various time frames.
>> >
>> > Here is an excerpt from an Automatic Analysis that I had to change to
>> > vertical in order to properly show it in this posting:
>> >
>> >
>> > Ticker MG851
>> > Date/Time 6/22/2007
>> > Name            Internet Service Providers
>> > Close  24.2
>> > 1P % -0.4
>> > 1P R 38      I inserted this 1 Day change rank
>> > 5P % 0.3
>> > 21P % 2       Want to add 5 day, 21 day, 63 day and 255 day Ranks
>> > 63P % 35
>> > 255P % 116
>> > NL 21 No
>> > ATR5 0.39
>> > ADR5 0.39
>> > HC 732.34
>> > L YR C 13.78
>> > YTD % 75.6
>> > YTD R 1         Another row I inserted to show YTD Rank
>> >
>> > So all I am trying to do is rank each of the percentage change columns
>> > from 1 to 240 (best to worst) in this one AA report.
>> >
>> > Any help would be appreciated.
>> >
>> > Regards,
>> >
>> > Dave
>> >
>> >
>> >
>> > Please note that this group is for discussion between users only.
>> >
>> > To get 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
>> >
>> >
>> >
>>
>
>
>
>
> Please note that this group is for discussion between users only.
>
> To get 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
>
>
>



Please note that this group is for discussion between users only.

To get 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/