PureBytes Links
Trading Reference Links
|
All,
I usually construct stock picking Excel spreadsheets in which I
create percentile ranks for things like returns of a stock relative
to the market, EPS Growth, Sales Growth, etc. Somewhat similar to
what can be found in Investor's business daily.
I am trying to develop a percentrank function in Amibroker. I
thought I had, but it assumed a normal distribution and recent
analysis of distributions and probability curves has showed me that
returns are not normally distributed and, in fact, are different
during differing market environments (bull vs bear).
Anyway, what I'd like to do is create my own %Rank statistic using
the new Percentile function such that it samples the ROC(C,260) for
all the stocks in my database and compares them to each other each
day. In essence duplicating what IBD does after a fashion.
One way I thought of to do this was to create a temporary reference
index of all the ROC's for each stock in my database for a given
day, perform a percentile rank on the set of ROC's and then use a
ten segment line fit of the cumulative probability (m*x+b), and
store the slope and intercept of each of the lines for each day as
11 separate reference indices. This would essentially map out the
distribution for the market for that day and Relative Strength ranks
could be easily extracted from that data.
Suppose I have 3000 stocks in my database and I have 5 years of data
for each stock. Will AB allow me to create an index say
called '~R260temp' which contains all the ROC(C,260) information for
yesterday, perform a Percentile ranking on this ~R260temp index and
then increment the day to today?
The algorythm for say today would look something like this:
//-----------------------------------------------------------
// First seed the temprary variable for ROC(C,260) with the ROC's
// of all the stocks in in Group0
//-----------------------------------------------------------
list = CategoryGetSymbols( categoryGroup, 0 );
roc260=0;
count=0;
for( i = 0; ( sym = StrExtract( list, i ) ) != ""; i++ )
{
roc260[i]=LastValue(ROC(Nz(Foreign( sym, "Close" )),260));
count=count+1;
}
x=0;
y=0;
//-----------------------------------------------------------
// First Loop i goes through percentile ranks in
// increments of 10 from 1 to 99
// x = the %rank we are seeking
// y = the ROC(C,260) that fits in between x-1 and x+1
//-----------------------------------------------------------
lag=0;
for( i = 0; i<=10; i++ )
{
Flag=0;
for( j = 0; j<=count-1; j++ )
{
y[i]=i*10;
if(i<1) y[i]=2;
if(i>9) y[i]=98;
if(roc260[j]>=Percentile( roc260, count, y[i]-1 ) AND roc260[j]
<=Percentile( roc260, count, y[i]+1 ))
{ x[i]=roc260[j];
Flag=1;
}
}
}
//-----------------------------------------------------------
// I'm trying to store x & y in arrays to use for later screens.
// The (x,y) pair should roughly represent the cumulative probability
// of the database
//-----------------------------------------------------------
AddToComposite(y,"~yrank","C");
AddToComposite(x,"~xroc","C");
Buy=0;
//-----------------------------------------------------------
Anyway when I run this code I get a "subscript out of bounds error"
on the very first loop, the ROC seeding loop. I'm not sure why that
would occur. Any clues?
Incidentally, the way this would be used is as reference data for
the the cumulative probability distribution (CPD). This would pretty
much be a match for a Percentile Rank based RS score. Using the data
points from this you could construct a set of 10 equations that
would essentially curve fit the CPD with 10 lines.
Can anyone help with this effort. I think it would be a great
feature for Scans and Explorations in AA.
-ace
Send BUG REPORTS to bugs@xxxxxxxxxxxxx
Send SUGGESTIONS to suggest@xxxxxxxxxxxxx
-----------------------------------------
Post AmiQuote-related messages ONLY to: amiquote@xxxxxxxxxxxxxxx
(Web page: http://groups.yahoo.com/group/amiquote/messages/)
--------------------------------------------
Check group FAQ at: http://groups.yahoo.com/group/amibroker/files/groupfaq.html
Yahoo! Groups Links
To visit your group on the web, go to:
http://groups.yahoo.com/group/amibroker/
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/
|