PureBytes Links
Trading Reference Links
|
Fred:
Have a $10 cigar. A $100 bottle of wine. WOW. So good. Works perfectly.
Did I say thanks?
Ken
-----Original Message-----
From: amibroker@xxxxxxxxxxxxxxx [mailto:amibroker@xxxxxxxxxxxxxxx] On Behalf
Of Fred Tonetti
Sent: Saturday, May 10, 2008 6:19 PM
To: amibroker@xxxxxxxxxxxxxxx
Subject: RE: [amibroker] Re: Greybeard Topic - Sorting and Ranking Arrays
It gets the WL number from the Filter in the AA Window .
As far as you adding a column for ROC is concerned, you didn't post the code
so I can't comment on it other then to say it is probably not written to
match the metric above.
If I add these two statements the first of which matches the metric above
and the second of which displays it.
ROCn = SelectedValue(ROC(C, 14));
AddColumn(ROCn, "ROC", 1.5);
Then what I get is below ... Looks correct to me ...
I think I made this change to the array initialization after I posted the
code.
rsSymNo = rsiSymNo = rocSymNo = rsScore = rsiScore = rocScore = Cum(0) -
99999999;
________________________________
From: amibroker@xxxxxxxxxxxxxxx [mailto:amibroker@xxxxxxxxxxxxxxx] On Behalf
Of Ken Close
Sent: Saturday, May 10, 2008 5:52 PM
To: amibroker@xxxxxxxxxxxxxxx
Subject: RE: [amibroker] Re: Greybeard Topic - Sorting and Ranking Arrays
Fred:
This is super. It sure shows me the methodology. I hope I can figure out the
internals to correct what I think is an error of some type.
At the moment, the statement:
WL = AA.Filter(0, "Watchlist") seems to be setting the watchlist (by
number)
that the CategoryGetSymbols command will use to retrieve ticker names.
However, I do not understand how this relates to the Filter dropdown box in
the AA window. I would think it would override the Filter drop down box, but
it works (except for a problem I will show below) if I leave it set to zero
in the statement and select different watchlists via the drop down menu. If
I substitute any other number in the statement, the Rank Scores are all
blank (not zero). So I have to puzzle that one out.
But more challenging will be this issue:
I added two columns for RSI and ROC so I could sort by those values and see
if the ordinals matchup. Note RSI column sorted and ordinals line up
incrementally from 1 to 17, as they should.
Ticker Date/Time RSI ROC Tot RSI() ROC14 DIS 5/8/2008 1 17 18 71.63 10.31 AA
5/8/2008 2 2 4 67.67 9.88 BA 5/8/2008 3 3 6 64.84 8.26 IBM 5/8/2008 4 12 16
63.39 0.82 INTC 5/8/2008 5 6 11 61.04 4.39 HPQ 5/8/2008 6 10 16 60.37 1.83
MCD 5/8/2008 7 8 15 59.99 2.52 WMT 5/8/2008 8 11 19 58.82 1.51 CAT 5/8/2008
9 16 25 58.53 -3.35 VZ 5/8/2008 10 5 15 58.12 6.16 UTX 5/8/2008 11 9 20
57.25 2.14 AXP 5/8/2008 12 4 16 57.13 7.29 T 5/8/2008 13 7 20 54.76 3.60 JNJ
5/8/2008 14 14 28 53.87 0.59 HON 5/8/2008 15 7 22 51.47 -2.67 DD 5/8/2008 16
15 31 51.12 -5.17 JPM 5/8/2008 17 13 30 50.49 0.63
But now sort by ROC14 and the ROC column ordinals do not match up. I would
expect the ROC ordinal column to line up incrementally from 1 to 17. DIS
should have an ordinal total of 2 instead of 18. (I think)
Ticker Date/Time RSI ROC Tot RSI() ROC14 DIS 5/8/2008 1 17 18 71.63 10.31 AA
5/8/2008 2 2 4 67.67 9.88 BA 5/8/2008 3 3 6 64.84 8.26 AXP 5/8/2008 12 4 16
57.13 7.29 VZ 5/8/2008 10 5 15 58.12 6.16 INTC 5/8/2008 5 6 11 61.04 4.39 T
5/8/2008 13 7 20 54.76 3.60 MCD 5/8/2008 7 8 15 59.99 2.52 UTX 5/8/2008 11 9
20 57.25 2.14 HPQ 5/8/2008 6 10 16 60.37 1.83 WMT 5/8/2008 8 11 19 58.82
1.51 IBM 5/8/2008 4 12 16 63.39 0.82 JPM 5/8/2008 17 13 30 50.49 0.63 JNJ
5/8/2008 14 14 28 53.87 0.59 HON 5/8/2008 15 7 22 51.47 -2.67 CAT 5/8/2008 9
16 25 58.53 -3.35 DD 5/8/2008 16 15 31 51.12 -5.17
(If the tables get messed up column wise, try changing the font to courier
new to get them to line up)
So I have some debug work to do to try and figure this out. But what a great
learning step and it is aimed at my exact problem.
Many thanks for doing this. I suspect many others on this list will benefit
too from this as a learning tool.
If you have any comments about the above, fire away.
Ken
-----Original Message-----
From: amibroker@xxxxxxxxxxxxxxx <mailto:amibroker%40yahoogroups.com>
[mailto:amibroker@xxxxxxxxxxxxxxx <mailto:amibroker%40yahoogroups.com> ] On
Behalf Of Fred Tonetti
Sent: Saturday, May 10, 2008 3:43 PM
To: amibroker@xxxxxxxxxxxxxxx <mailto:amibroker%40yahoogroups.com>
Subject: RE: [amibroker] Re: Greybeard Topic - Sorting and Ranking Arrays
Ken,
This could be generalized even more but it suffices for proof of concept
with two metrics.
You can do the rest .
AB = CreateObject("Broker.Application");
AA = AB.Analysis;
WL = AA.Filter(0, "WatchList");
WLSyms = CategoryGetSymbols(categoryWatchlist, WL);
rsSymNo = rsScore = rsiSymNo = rsiScore = rocSymNo = rocScore = Cum(0);
rsScore[0] = rsiScore[0] = rocScore[0] = 1e100;
procedure Rank_Sym (rsSymNoX, rsScoreX)
{
rsSymNo = IIf(rsScoreX > rsScore, IIf(rsScoreX <= Ref(rsScore, -1),
rsSymNoX, Ref(rsSymNo, -1)), rsSymNo);
rsScore = IIf(rsScoreX > rsScore, IIf(rsScoreX <= Ref(rsScore, -1),
rsScoreX, Ref(rsScore, -1)), rsScore);
}
if (Name() == StrExtract(WLSyms, 0))
{
WLQty = 0;
for (i = 0; (Symbol = StrExtract(WLSyms, i)) != ""; i++)
{
WLQty = WLQty + 1;
SetForeign(Symbol);
RSIx = SelectedValue(RSI(14));
ROCx = SelectedValue(ROC(C, 14));
RestorePriceArrays();
rsSymNo = rsiSymNo;
rsScore = rsiScore;
Rank_Sym (i, RSIx);
rsiSymNo = rsSymNo;
rsiScore = rsScore;
rsSymNo = rocSymNo;
rsScore = rocScore;
Rank_Sym (i, ROCx);
rocSymNo = rsSymNo;
rocScore = rsScore;
}
for (i = 1; i <= WLQty; i++)
{
StaticVarSet("RSI_Rank_" + NumToStr(RSISymNo[i], 1.0), i);
StaticVarSet("ROC_Rank_" + NumToStr(ROCSymNo[i], 1.0), i);
}
}
for (i = 0; i <= 1000; i++)
{
if (Name() == StrExtract(WLSyms, i))
break;
}
RSI_Rank = StaticVarGet("RSI_Rank_" + NumToStr(i, 1.0));
ROC_Rank = StaticVarGet("ROC_Rank_" + NumToStr(i, 1.0));
Tot_Rank = RSI_Rank + ROC_Rank;
Filter = BarIndex() == SelectedValue(BarIndex());
AddColumn(RSI_Rank, "RSI", 1.0);
AddColumn(ROC_Rank, "ROC", 1.0);
AddColumn(Tot_Rank, "Tot", 1.0);
________________________________
From: amibroker@xxxxxxxxxxxxxxx <mailto:amibroker%40yahoogroups.com>
[mailto:amibroker@xxxxxxxxxxxxxxx <mailto:amibroker%40yahoogroups.com> ] On
Behalf Of Ken Close
Sent: Saturday, May 10, 2008 7:41 AM
To: amibroker@xxxxxxxxxxxxxxx <mailto:amibroker%40yahoogroups.com>
Subject: RE: [amibroker] Re: Greybeard Topic - Sorting and Ranking Arrays
Droskill: Thanks for your suggestion. I did not explain exactly what I am
trying to accomplish, so this is a little away from my objective.
As I put in another reply (to Tomasz) on this subject,
"What I need to achieve is equivalent to using the Excel Function RANK,
which allows the specification of a Range (a column for say, stochastics for
100 funds), then getting in another column the Ordinal Position of that
ticker relative to all others for the result of stochastics. Then, another
column might have an indicator, say RSI14, and another column using RANK
that shows the Ordinal Position of each RSI value for all tickers. I then
take a final column and say, sum the two ordinal values for each ticker to
get a Master Ranking column. My situation is more complex than this (more
columns and a more complex combining method) but this is the basic idea.
This can all be done in Excel, but a tremendous labor saving step is to
accomplish it all in AB. Imagine trying to do this on 1000s of stocks on a
daily or even hourly basis."
Thus, I am left with trying to manipulate the various columns, perhaps with
an ATC for each column, but the looping I envision will be necessary will
likely make this kind of an approach too slow.
Another way to get to a master ranking of ordinal positions of two or more
indicators is to take each indicator and multiply them together for each
ticker (RSI times stochastics times etc) and use the overall product as a
ranking "score". However, the Ordinal Position for each intermediate
indicator has appeal in a display that others look at, even as all issues
are sorted by this so-called MasterRanking parameter. Thus this
multiplication route, while it "might" work, loses some functionality from
the overall output.
I appreciate you making the suggestion. Any other ideas?
Ken
-----Original Message-----
From: amibroker@xxxxxxxxxxxxxxx <mailto:amibroker%40yahoogroups.com>
<mailto:amibroker%40yahoogroups.com>
[mailto:amibroker@xxxxxxxxxxxxxxx <mailto:amibroker%40yahoogroups.com>
<mailto:amibroker%40yahoogroups.com> ] On Behalf Of droskill
Sent: Friday, May 09, 2008 5:19 PM
To: amibroker@xxxxxxxxxxxxxxx <mailto:amibroker%40yahoogroups.com>
<mailto:amibroker%40yahoogroups.com>
Subject: [amibroker] Re: Greybeard Topic - Sorting and Ranking Arrays
I'll take a different tact - let me assume you just want to display the
ranking on the screen rather than a backtest - so that's an Exploration.
Here's quick sample Exploration - I'm not saying there is any value to these
measurements - they are for demonstration only.
MAShort = MA (C,20);
MALong = MA (C,100);
PS = ROC(C,250);
MAps = MA(PS,50); //Do a calculation based on another number
BuySignal = MAShort > MALong;
SellSignal = MAShort < MALong;
Filter = Status("lastbarinrange"); //Filter to only show last bar AddColumn(
BuySignal,"Buy"); AddColumn( SellSignal,"Sell"); AddColumn( C, "Close");
AddColumn( MAShort,"MAShort"); AddColumn( MALong,"MALong"); AddColumn(
PS,"PositionScore"); AddColumn( MAps,"MA of PS"); SetSortColumns(-3); //this
sets the sorting column
--- In amibroker@xxxxxxxxxxxxxxx <mailto:amibroker%40yahoogroups.com>
<mailto:amibroker%40yahoogroups.com> , "Ken Close" <ken45140@xxx> wrote:
>
> It has been fun to search the yahoo archives back to 2002 and see
names of a
> lot of the original folks who got on the Amibroker bandwagon back in
> the early days, many of whom are no longer around (at least not
> posting like they used to). Boy, how the program has evolved and
> improved over these many years.
>
> I was looking back there in the archives for messages on the Osaka
Plugin
> (which is still on my hard drive since 2002 but which I have never
used).
> Maybe now......
>
> I have a need to take a watchlist and position rank several columns of
> calculations and determine the postion rank of the ticker for that
> calculation; then do the same for another column (calculation), get
> the position rank for that additional column, and then combine the
> position ranking numbers for the columns for each ticker, sort of to
> get a Master ranking parameter.
>
> My question is: what new features in AB might help accomplish this?
Surely
> the Osaka Plugin (2002 vintage) is not the only way to do what I
want. I
> have not really studied nor used Static and Dynamic variables---is
this the
> set of commands that I would use with looping to get position ranks of
> a watchlist?
>
> I did find and just tested some code from the Library which used
just these
> tools (variables and looping) and it was painfully slow and would
not really
> work for the application I have in mind. I am uncertain if the code
in that
> example can be modified to make it faster.
>
> Any suggestions about this age-old question/problem, given the many
advances
> of Amibroker since 2002??
>
> Thanks for any ideas (the more specific the better).
>
> Ken
>
------------------------------------
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/ <http://www.amibroker.com/devlog/>
<http://www.amibroker.com/devlog/ <http://www.amibroker.com/devlog/> >
For other support material please check also:
http://www.amibroker.com/support.html
<http://www.amibroker.com/support.html>
<http://www.amibroker.com/support.html
<http://www.amibroker.com/support.html> > Yahoo! Groups Links
No virus found in this incoming message.
Checked by AVG.
Version: 8.0.100 / Virus Database: 269.23.14/1425 - Release Date:
5/9/2008
12:38 PM
No virus found in this incoming message.
Checked by AVG.
Version: 8.0.100 / Virus Database: 269.23.15/1426 - Release Date:
5/10/2008
11:12 AM
No virus found in this incoming message.
Checked by AVG.
Version: 8.0.100 / Virus Database: 269.23.15/1426 - Release Date: 5/10/2008
11:12 AM
------------------------------------
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/
|