PureBytes Links
Trading Reference Links
|
Ken,
Just a note on semantics; You said:
"If run = 1, then OpenInt will be assigned to k whatever value k is"
Technically, OpenInt will be set to k. Or, conversely, k will be
assigned to OpenInt. But, OpenInt will not be assigned to k.
I believe that that is what you meant. But, just making sure ;)
Mike
--- In amibroker@xxxxxxxxxxxxxxx, Ken Close <ken45140@xxx> wrote:
>
> Paul:
>
> You asked:
> By the way, Would it be better to store the results of all 11
rankings
> rather than the sum of rankings
>
> Why? Would doing so offer a speed advantage in some way?
> Right now, I have some auxilliary needs to show which was ranked
first by
> UPI or which was ranked first by Maxdd, then the sum combines all
indicators
> and the symbols that individually did best on each one will come to
the top
> with the sum.
>
> Can someone share some words about += operator.
>
> The Help definition: Add the value of the second operand to the
value of
> the first operand; store the result in the object specified by the
first
> operand
> So in this code portion
>
> There was this section of code that I shared in another message,
and I do
> not understand how to read it.
>
> if(qt)
> {
> if(run == 1)
> qt.OpenInt = k;
> else
> qt.OpenInt += k;
> }
>
> It says that If run = 1, then OpenInt will be assigned to k
whatever value k
> is
> Otherwide, k is added to OpenInt and then stored in OpenInt . . . .
Is this
> just a handy way of writing OpenInt = OpenInt + k; ???
>
> What is the benefit of this, or in what circumstance do you want to
use it
> vs Variable = Variable + second variable??
>
> Thanks for any insights.
>
> Ken
>
>
>
>
>
>
>
>
> _____
>
> From: Paul Ho [mailto:paul.tsho@...]
> Sent: Tuesday, July 08, 2008 8:59 AM
> To: 'Ken Close'
> Subject: RE: [amibroker] Re: Paul Ho: Memory Challenges with Great
Ranking
> Tool
>
>
> Ken
> I think what you can do is to write a function call UPI. also since
rfann1
> is a constant. we shouldn't be wasting CPU power to calcuate it
again and
> again just enter it in as a constant;
>
> function UPI(fund, rfann1, period1)
> {
>
>
> TotGain1 = ROC(fund, period1);
>
> AnnGain1 = Nz(100 *((TotGain1/100+1)^(252/period1)) - 1);
>
> Hfund = Highest(fund)
>
> Dr = (Hfund - fund)/Hfund;
>
> UI = 100 * sqrt(sum(Dr^2, period1)/period1); // you didnt have a
> formula, this is mine for UI
>
> UPI1 = Nz((AnnGain1 - rfann1) / UI);
>
> return UPI1;
>
> }
>
>
> Now you basically replace the ROC & RSI function that you have been
using
> with this one in all your ranking....
> ......
> mOwnUPI = UPI(c, 14, 5); // rfann1 = 5 or whatever you deem it to
be.
> for(i = 0; (sym = StrExtract(List, i)) != ""; i++)
>
> {
>
> SetForeign(sym);
>
> mUPi = UPI(C, 14, 5);
>
> RestorePriceArrays();
>
> n2 = !IsNull(mUPi);
>
> // RSICount += n;
>
> UPIrank = IIf(Nz(mUPi) > mOwnUPi, UPIrank + n, UPIrank);
>
> }
>
>
> Keep working at it, you are getting there.
> By the way, Would it be better to store the results of all 11
rankings
> rather than the sum of rankings
> Cheers
> Paul.
>
>
> _____
>
> From: Ken Close [mailto:ken45140@...]
> Sent: Tuesday, 8 July 2008 10:05 PM
> To: 'Paul Ho'
> Subject: RE: [amibroker] Re: Paul Ho: Memory Challenges with Great
Ranking
> Tool
>
>
> Good morning:
>
> I still have not resolved all of my database problems and posted a
note to
> Tomasz.
>
> Meanwhile, can you advise on this:
> As I want UPI and other indicator calcs to be part of the ranking
> (forgetting for the moment about speed issues), is this the way I
need to
> structure the statements:
>
> A bunch of calcs first to establish the equivalents to the "myOwn"
> variables.
>
> Then a loop for each symbol in the watchlist
>
> SetForeign
>
> Repeat of the calcs/statements
>
> RestorePriceArrays()
>
> then a bunch of mrank statements
>
> Exit the loop
>
> Then repeat the same statements again?
>
> Here is an example--can you tell me if I am expanding the concept
correctly?
> (It is sad commentary on my detailed skills that I still can not
explain why
> your code works, only that it does.)
>
> Ken
>
> Example for UPI:
> list = CategoryGetSymbols(categoryWatchlist, 19);
>
>
>
> TotGain1 = ROC(fund, period1);
>
> AnnGain1 = Nz(100 *((TotGain1/100+1)^(252/period1)) - 1);
>
> rfGain1 = ROC(riskfree, period1);
>
> rfAnn1 = Nz(100 *((rfGain1/100+1)^(252/period1)) - 1);
>
> UPI1 = Nz((AnnGain1 - rfann1) / UI1);
>
> Maybe mOwnUPI1 = Nz((AnnGain1 - rfann1) / UI1);
>
>
>
> for(i = 0; (sym = StrExtract(list, i)) != ""; i++)
>
> {
>
> SetForeign(sym);
>
>
>
>
>
> All again
>
> M1 = Nz((AnnGain1 - rfann1) / UI1);
>
> RestorePriceArrays();
>
>
>
> Then a bunch of these:
>
> m1rank = IIf(Nz(m1) > mOwnUPI1, m1rank + n, m1rank);
>
> m2rank = IIf(Nz(m2) > mOwn2, m2rank + m, m2rank);
>
>
>
>
>
> }
>
>
>
> Then again. . .
>
>
>
> Very complex
>
>
> _____
>
> From: Paul Ho [mailto:paul.tsho@...]
> Sent: Tuesday, July 08, 2008 6:11 AM
> To: 'Ken Close'
> Subject: RE: [amibroker] Re: Paul Ho: Memory Challenges with Great
Ranking
> Tool
>
>
> Ken
> The problem you are facing is similar to what I did when I first
started
> using the OI field. My data vendor provides updates in metastock
format, and
> I was using the metastock plug-in. In the beginning, I didn't have
local
> data storage enabled, so there was no way the OI field could be
changed.
> However, even after i have enabled local storage. I would only be
able to
> see the values in OI temporarily, It was very soon overwriten by
reads from
> the Metastock database, I have finally made my database local (ie
data
> source = local database in database setting). Then the OI field was
saved. I
> think fast track plugin works the same way. I suggest you make a
complete
> copy of the directory containing your fast track database. rename
the
> directory, and open AB and load this copied database, go to database
> settings and change the data source to local. In this way, you
havent done
> anything to original database, but you are able to save the OI
field. What
> is probably more important is how you're going to bring in new data
to this
> database. there are ways to do it. but it is not particularly
elegant.
> Anyway let see what your results are.
> By the way Is UPI Ulcer Performance Index or is that something else.
>
>
> _____
>
> From: Ken Close [mailto:ken45140@...]
> Sent: Tuesday, 8 July 2008 1:46 PM
> To: 'Paul Ho'
> Subject: RE: [amibroker] Re: Paul Ho: Memory Challenges with Great
Ranking
> Tool
>
>
> Paul:
>
> Almost midnight here, so quick summary before I hit my bed.
> My first run with your rank code went 22 minutes, better than the 1
hr 30
> min estimates I had been seeing but not great. Then I finally got
a new
> database set up with all of the best settings and a new import from
the FT
> db and a new list of sp500 symbols (481 this time). That run was
total of 7
> min 25 second in scan mode. About what I think you said you were
seeing.
>
> As far as OI field I know that the code is sticking the rankings in
as they
> show up with some code I wrote to explore (DJ30) and display the OI
field.
> However, it does not stick because I apparently still have the
FastTrack
> database reading the api instead of the local that I called for. I
will
> have to followup with Tomasz in the morning on why I can not get it
to
> convert to local storage.
>
> I had run the backtest code, but I do not see any data that I wrote
down. I
> think I did the DJ30 again. Verified that the OI field was filled
(but
> erased again), but no timing on SP500. I will repeat all tests
tomorrow and
> send a comparison at that time.
>
> One thing I will like your suggestions on...I really have to take
this up to
> 11 indicators, but several of them are multi-line indicators, like
UPI. So,
> I will attempt to figure out what to put in front of the loop, what
to put
> inside the loop, and what to put after the loop in order for all of
the
> indicators to be processed into one total sum of ranks. Since the 2
> indicator approach took the 7 minutes, I am going to guess that 11
> indicators, especially when most of them are multi-
line/multivariable
> affairs will not prove practical on large lists, but may work with
selected
> ETFs say 150 to 175 symbols.
>
> anyway, more than I can describe here now and I too am off to bed.
>
> Thanks,
>
> Ken
>
> _____
>
> From: Paul Ho [mailto:paul.tsho@...]
> Sent: Monday, July 07, 2008 11:21 AM
> To: 'Ken Close'
> Subject: RE: [amibroker] Re: Paul Ho: Memory Challenges with Great
Ranking
> Tool
>
>
> Ken,
> I am sending you 2 AFL file.
> you must run it with local storage enabled. better still make it a
local
> database, you could change it back after the test. Set QuickAFL on,
and run
> it for from 2003 to 2008. No padd and align. daily bars these will
be set
> as base line run, you can vary these settings in later runs. You
can leave
> the system utilities as it is, unless it becomes too slow.
> the first file is N^2 algorithm, you need to run scan, not explore.
> Exploration is much slower than scan because of window refresh.
When scan is
> finished, check to see if the OI fields are populated.
> the 2nd file is custom backtest. run optimization with the same
settings as
> above. you can alter the max pos based on how many stocks you want
to rank,
> I have made it 50 as default, which should allow you 100 rankings.
check OI
> fields afterwards, you can also turn on the the fputs to local csv
files if
> you want. So if you want to rank the top 500 stocks, then you have
to set it
> to 250 eventually (I'm not too sure, try and see). otherwise only
the top
> 100 will have rankings. Anyway start off with 50 max pos and see
how long it
> takes before increasing it to a higher number.
> let see how you get on. I'll be interested in your comparsion light
for
> light (500 stocks in each case).
> I think you should be on your way once you have setup your
databases/aa
> setting "correctly".
> I'm off to bed now. It is 1.18 in the morning.
>
>
> _____
>
> From: Ken Close [mailto:ken45140@...]
> Sent: Tuesday, 8 July 2008 12:40 AM
> To: 'Paul Ho'
> Subject: RE: [amibroker] Re: Paul Ho: Memory Challenges with Great
Ranking
> Tool
>
>
> Paul:
>
> Well, now, something different. We had never discussed database
sources
> before.
>
> My previous problems were with the FastTrack database, and
retreiving the
> data from the original database (no local storage enabled).
>
> I canceled a QuotesPlus plan last October but still had the
database intact
> (1998 through Oct, 2007 data), with local storage enabled.
>
> So I repeated a run with the QuotesPlus data, SP500, 462 symbols,
and
> results much different.
>
> Now, your single indicator completed !! in 40 seconds. !!!
> I changed to my two indicator modification, and got slower but now
the
> progress bar showed 10% complete and 22 min est time at end of 3
minutes
> (did not run to completion).
>
> So things are clearly faster with the different database. Perhaps
it is the
> local storage enabled vs the API (QuotesPlus vs the FastTrack).
>
> Re your questions:
> Explore of course--a scan would not show any results, yes?
> A pain to unload the utilities, but I can do so when I get further
along,
> ie, trying more indicators.
> The tests above were run with a realtime data collection system
running
> (QuoteTracker which pulls about 50 symbol updates from Fidelity
every 60
> seconds), plus mail and my browser running too.
>
> I will still need all the help I can get (Tomasz made a nice offer
but I
> will be you can help me get to the end goal too).
> The test with two indicators was a definite slowdown compared to
one.
> My goal is to do it with 11 indicators. Gulp. Why 11?
> For your ears only, please do not repeat, but I am helping
automate a
> manual system now done in Excel, which ordinal ranks a recipe of 11
> indicators and then the rankings are hand selected for real time
rotational
> trading once per month. I have analyzed equity curves and this
manual system
> has returned a 17% CAR and 23% MaxDD since 2000. Not really bad,
and could
> be better if it could be automated for optimization and walkforward
testing.
> So my motivation is high, but the hurdles substantial. I should
say that I
> do not know if similar good results could be obtained from
a "recipe" of
> indicators that are somewhat less than 11.
>
> It is now 10:40am on the East coast (southern Ohio really). What
time is it
> there when you reply?
>
> Ken
>
> _____
>
> From: Paul Ho [mailto:paul.tsho@...]
> Sent: Monday, July 07, 2008 9:39 AM
> To: 'Ken Close'
> Subject: RE: [amibroker] Re: Paul Ho: Memory Challenges with Great
Ranking
> Tool
>
>
> Ken
> I thank you on behalf of the Alzheimer's Foundation.
> Now before I do anything else, can you tell me if your are doing
scan or
> exploration when you time it?
> Second, Do you think you can unload all your virus checking and
other system
> utilities during the run. if you're worried about safety, you can
disabled
> internet connection during that time. I think some of them are
using so much
> of your bandwidth that its like trying to box with one arm tied
behind your
> back. We got about an hour window before I have to crawl back in my
cave to
> hiberate, So let see what we can do. When you come back, I'm going
to give
> you a couple of afls to run.
> /Paul.
>
>
>
> _____
>
> From: Ken Close [mailto:ken45140@...]
> Sent: Monday, 7 July 2008 11:13 PM
> To: paul.tsho@xxx
> Subject: RE: [amibroker] Re: Paul Ho: Memory Challenges with Great
Ranking
> Tool
>
>
> Greetings Paul:
>
> I want to express my appreciation for all the help you have been
providing.
> I just clicked through a $30 donation to the Alzheimer's Foundation
in your
> name, as per your suggestion several messages ago. Can't say that
I have
> ever done something like that, but OTOH, you have given me help
beyond
> measure and it has advanced some important work I need to do.
>
> Now. . .to try and advance further:
>
> I can get nothing more than 1 hour 30 minutes with my 425 symbol
list for
> the SP500 (what!?), even with your original code--one indicator (you
> remember that I published a modification to your code where I added
a second
> indicator).
>
> I will list my system stats:
> 2.2 GHz AMD Athalon 64
> 3072 MB Ram
> Plenty of hard drive space.
> Regularly defragged HD
> I use Belarc system profiler (it says I have 12 outstanding
security files
> to download)
> I have a bunch of system tray utilities which run
> - several AV watchdogs
> - Copernic Desktop Search (set to index in the nighttime AM)
> - several other helper applications
> - one application to optimize RAM
> - one application to regulate CPU cycles priorities (but I have
disabled it
> for these tests)
> AB 5.14
> Unload all other general applications--only AB running
> Reboot computer to permit a "clean memory" situation (other than
the tray
> applications)
>
> Run 425 symbols (my SP500 list)
> Set AB to max symbols = 500 (was 125)
> Set AB mem to 500 MB (was 250)
> QuickAFL generally OFF (turned on did not make a difference)
> Pad and Align OFF
>
> Stopwatch on, but it did not really matter
> Clicked cancel at 3 minutes on stopwatch
> Usually took 30 to 45 seconds for Cancel command on status box to
take
> effect
> Status box usually said 2% of symbols processed with 1 hr 30min to
1hr 50min
> remaining.
> Number of rows showing once Cancel took effect = 20 to 25
>
> One last thing, I set the Filter to
>
> Filter = BarIndex() == SelectedValue(BarIndex());
>
> Rather than Filter = 1; I think I tried Filter = 1 once and it did
not seem
> any different.
>
> Smaller lists like NDX (n = 99) processed fairly quickly (less than
1
> minute).
> As I await your reply, I think I will load a new SP500 list into a
new
> Watchlist.
>
> Finally (really), I get my data from the FastTrack database through
the AB
> FT API. Could this make a difference?
> If yes, what would I do different?
>
>
> Can you suggest something else I can look at.
>
> Again, many thanks.
>
> Ken
>
>
>
>
>
>
>
>
> _____
>
> From: amibroker@xxxxxxxxxxxxxxx [mailto:amibroker@xxxxxxxxxxxxxxx]
On Behalf
> Of Paul Ho
> Sent: Monday, July 07, 2008 3:29 AM
> To: amibroker@xxxxxxxxxxxxxxx
> Subject: RE: [amibroker] Re: Paul Ho: Memory Challenges with Great
Ranking
> Tool
>
>
> Ken
> As you know, the algorithm that I gave you increase dramatically
with the
> size of the watchlist. However, the times that you stated isn't in
line with
> what I experience. I tried my code (which is similar to yours, with
> exception that it also stores the value in OI) on 2 machines. One
very old
> machine, a single core AMD which is about 5 years old, Window tells
me it is
> an AMD XP 2600 with 1G of ram. I use a watchlist of 472 symbols,
running
> from 1/1/2000 to now. the time taken is 6.5 minutes (from the
progress bar).
> and on a newer machine Core 2 duo E6600, it took just over 1
minute. So
> this is very different to the one and a half hour that you are
talking
> about.
> So I am wondering what machine you're running on. and what kind of
AA
> setting you use? What I will suggest is that you DONT Check pad
and align,
> this will increase the number of bars by quite a lot. You can check
QuickAFL
> though.
> I have also given you a few suggestions in one of the other posts,
including
> monthly bars, normalisation of scores etc
> http://finance.groups.yahoo.com/group/amibroker/message/126336. Did
you take
> a look at that?
> Despite its shortcoming, I think the N^2 algorithm will still
perform
> better/faster than Bruce's suggestions. Pad and Align &/or ATC will
slow it
> down even more. In the past, I have made a ranking dll which uses a
2
> dimensional array, and basically insert the stock into the right
ranking
> order as each symbol is scanned, a little bit like Fred's algorithm
but on a
> total array basis. That is certainly very fast. In addition,
Tomasz's custom
> Backtester code has the potential also to be quite fast without the
use of
> dll. I have ported the code so it stores directly in the OI during
after
> optimization. However, it comes back with an internal error in
certain
> instances if the watchlist gets over 1400 symbols and no of bars is
more
> than 2500. I have sent it to Tomasz for him to have a look at, when
he comes
> back. I can share that with you. But my point is that the N^2 idea
should be
> fast enough for what you are talking about ~500 stocks. You see
there is a
> big difference between 1 minute and 1 and half hour.
> Send me a private email if you like, I'm curious why there such a
big
> difference.
> Cheers
>
>
>
>
>
> _____
>
> From: amibroker@xxxxxxxxxxxxxxx [mailto:amibroker@xxxxxxxxxxxxxxx]
On Behalf
> Of Ken Close
> Sent: Monday, 7 July 2008 7:40 AM
> To: amibroker@xxxxxxxxxxxxxxx
> Subject: RE: [amibroker] Re: Paul Ho: Memory Challenges with Great
Ranking
> Tool
>
>
>
> Bruce:
>
> Thanks for giving me another way to go.
>
> In case you have been following (or remember) this topic from a
ways back,
> Fred was generous enough to write me a code concept for doing all
of this
> (but end of range only) and I successfully converted it to
my "endpoint"
> recipe of 11 or so indicators. It did ok for relatively large
watchlists
> (even the RUT) but could not handle very well some much larger
watchlists in
> the many 1000s. But, it gave me a combined ranking on any end point
date I
> set in the AA window. My absolute minimum requirement is to create
> combo-rank-scores on a monthly basis but I was pleasantly surprised
when
> Paul Ho served up a concept to create daily combo-rank-scores on a
daily
> basis, but then euphoria changed to despair as I encountered the
n^2 time
> factor.
>
> So, thanks to you and others I have a variety of ways to consider
getting to
> the end of this problem.
>
> 1. Your suggestion of normalized indicators and using a final
percentage
> value as the combo rank.
>
> 2. Taking Fred's code and finding a way to manipulate the
EndofRange date,
> basically repeating his code over and over on the same watchlist
but with
> changing EndofRange dates. (I still have to do something with the
collection
> of combo-scores I will accumulate by date, but that is another
issue.*** see
> below) I have even considered manually repeating the process to the
end
> point (only 12 runs per year x the 8 years I want to test over).
>
> 3. Taking Paul Ho's code which ranks daily and either living with
the
> limitation in the Watchlist population or running the thing over
night.
> Since I have speed problems now with 2 indicators and 150+ symbols,
I
> probably will drop off the cliff with 11 indicators and the same
150+
> symbols. An alternate which I plan to test next is to see how
Paul's code
> performs on a Weekly or even Monthly compressed basis, although if
symbol
> number is controlling and not barcount, then this will not do much
good.)
>
> 4. Using Tomasz's suggestion of the custombacktester, making 11
separate
> runs, then somehow combining the 11 different output reports,
coming up with
> a combo-rank that way.
>
> If you were approaching this, can you guess and say which approach
you would
> concentrate on. Right now, number 4 looks like it actually might be
the
> least programming and execution intensive, but I am not sure. I
also have
> to have a way of updating the entire system as time goes forward.
That will
> bring an additional set of challenges I am sure.
>
> Thanks for stepping in.
>
> Ken
>
> *** Paul Ho shared a small COM code snippit that sticks an
indicator nicely
> into the OI field of a symbol, so that is the approach I want to
take once I
> have the combo-rank to stick in the right place. Talk about
complex......
>
> PS: Bruce, if you are still reading, would I have a better chance of
> executing my task in Trade vs Amibroker (sorry Thomasz)?
>
> -----Original Message-----
> From: amibroker@xxxxxxxxx <mailto:amibroker%40yahoogroups.com>
ps.com
> [mailto:amibroker@xxxxxxxxx <mailto:amibroker%40yahoogroups.com>
ps.com] On
> Behalf
> Of bruce1r
> Sent: Sunday, July 06, 2008 5:03 PM
> To: amibroker@xxxxxxxxx <mailto:amibroker%40yahoogroups.com> ps.com
> Subject: [amibroker] Re: Paul Ho: Memory Challenges with Great
Ranking Tool
>
> Ken -
>
> I'm too involved with something else right now, but let me see if I
can
> offer quick suggestion. First -
>
> 1. Tomasz is pointing out the solutions in (N^2) time are never
practical
> past some limit. That means that the execution time goes up with
the square
> of the number of items - ticker in this case. There are a couple of
> programming tricks that you can play, but I don't think that they
are going
> to get you where you want to go -
>
> For example, programming tricks can be used to make the N^2
comparison
> matrix "triangular". This reduces the comparisons by half.
>
> You might use Pad and Align to a ticker with a short history to cut
the time
> further.
>
> But, this is still going to leave you in a long timeframe.
>
> 2. It looks like you are trying to add unbounded indicators and use
the
> ordinal values to normalize them so that they can be combined.
> Use of the custom backtester would still require that you generate
output
> for each indicator and then combine them.
>
> Another approach might be to go out of the box a little and
question your
> basic assumption. Here's what I mean.
>
> Ordinal values can be used to convert unbounded ranges (such as
ROC) to
> bounded values. But they can do some strange things to outliers.
> For example, consider these points. Say they are for tickers
A,B,C,D,E on a
> particular day -
>
> 0, 20, 21, 22, 200
>
> The point 22 is ranked #2 (higher value better) when it is not near
the top.
>
> ON THE OTHER HAND, range value can be used also to convert
unbounded data to
> bounded. THEY REQUIRE A PRE-SCAN TO KNOW THE MIN AND MAX.
> For the range above, it would convert to the following percentages -
>
> 0, 10, 10.5, 11, 100
>
> This has some advantages for certain data distributions, but some
> disadvantages for others. For data where the probability of
outliers is
> low, it yields similar results.
>
> SO, HERE'S WHAT YOU MIGHT DO.
>
> 1. Take a watchlist and start a Exploration pass. When
> Status("stocknum") == 0, loop through the list and find the global
Min and
> Max for each bar across all of the tickers for a given indicator
and store
> it in an ATC in the H and L fields. For RSI and ROC, you would have
2 ATC's
> - say ~MINMAX_ROC and ~MINMAX_RSI. This is 1 pass of all N tickers.
>
> 2. Continuing on for stocknum 0 and for 1 - N, calculate the ROC
and RSI and
> convert it to a percentage of the MIN and MAX range that you stored
in the
> ATC's for each bar -
>
> rangepcnt = ( tickscore - tickglobalmin ) / ( tickmax -
tickglobalmin
> ) * 100;
>
> 3. Now you can combine the range values because they are
normalized.
> If you divide by the number of indicators, you'll end up with a
combined
> percentage.
>
> Now, while this is not an ordinal rank, it works perfectly well for
scoring
> and is a solution in 2*N time. BTW - this reference won't mean much
to most
> here, but should to you - Ed Gilbert detailed this in Trade doc
almost a
> decade ago.
>
> -- BruceR
>
> --- In amibroker@xxxxxxxxx <mailto:amibroker%40yahoogroups.com>
ps.com,
> "Tomasz Janeczko" <groups@> wrote:
> >
> > Hello,
> >
> > No, look again. The code I provided gives the sort is ON BAR BY
BAR
> basis.
> >
> > Best regards,
> > Tomasz Janeczko
> > amibroker.com
> > ----- Original Message -----
> > From: Ken Close
> > To: amibroker@xxxxxxxxx <mailto:amibroker%40yahoogroups.com>
ps.com
> > Sent: Sunday, July 06, 2008 9:08 PM
> > Subject: RE: [amibroker] Paul Ho: Memory Challenges with Great
> Ranking Tool
> >
> >
> > Tomasz:
> >
> > Thanks for all the help you give to so many people, me included.
> >
> > However, while I did as you suggested with the custombacktester,
> and looked into the output file it produces, I am at a loss to know
how to
> use the data it contains. It is not all of the data that I need.
> >
> > I want the ordinal ranking of multiple indicators, add them all
> together, per bar and per symbol, and use the final sum, of the
ORDINAL
> ranks, as the ranking value for all symbols.
> >
> > This output represents what I want (but it is only for two
> indicators). I want to turn this into my "recipe" which will have
> approximately 8 to 10 indicators.
> >
> >
> >
> > I ran the custom backtest, opened the output.html file, and see
> that the symbols are sorted by the ranking value and it is indeed
an ordinal
> value. But, the sort is done only once (probably as a lastbar
> basis) and Paul Ho sorting algorithm gives me ordinal values for
each bar
> for each symbol (displayed above using a lastbar basis).
> >
> > You say Paul's code is inefficient, and maybe it is because it
> sorts all symbols by all bars. Can you suggest a change to the
specific
> code that would do what I want, but more efficiently?
> >
> > Again, thanks for all that you do.
> >
> > Ken
> >
> >
> >
> >
> ----------------------------------------------------------
> --
> > From: amibroker@xxxxxxxxx <mailto:amibroker%40yahoogroups.com>
ps.com
> [mailto:amibroker@xxxxxxxxx <mailto:amibroker%40yahoogroups.com>
ps.com]
> On Behalf Of Tomasz Janeczko
> > Sent: Sunday, July 06, 2008 1:39 PM
> > To: amibroker@xxxxxxxxx <mailto:amibroker%40yahoogroups.com>
ps.com
> > Subject: Re: [amibroker] Paul Ho: Memory Challenges with Great
> Ranking Tool
> >
> >
> > Hello,
> >
> > The code is inefficient because it repeats the sorting N*N times
> where N is number of symbols, while
> > only N times is enough.
> >
> > Ranking is a process that is done during first pass of backtest.
> It is implemented efficiently.
> > We can use this built-in process easily using custom backtest
> procedure as shown here:
> >
> > Note that this formula will not produce output in AA directly.
> Instead it will produce a HTML
> > file (output.html) that you can later import to AA using AA,
> File->Import
> >
> > Also please be warned that produced files are huge and attempt to
> load such big HTML file
> > into Internet Explorer instead will easily hang IE.
> >
> > PositionScore = ROC( C, 14 ) + 1000; // WHAT YOU WANT TO RANK
> >
> > SetOption("MaxOpenPositions", 10 );
> > SetBacktestMode( backtestRegularRaw );
> > Buy=1;
> > Sell=0;
> > SetCustomBacktestProc("");
> > if( Status("action")==actionPortfolio )
> > {
> > bo = GetBacktesterObject();
> >
> > bo.PreProcess();
> >
> > dt = DateTime();
> >
> > fh = fopen("output.html", "w" );
> >
> >
> fputs
("<TABLE><TR><TH>Symbol</TH><TH>Date/Time</TH><TH>Rank</TH></TR>\n",
> fh );
> >
> > for( i = 0; i < BarCount; i++ )
> > {
> > k = 1;
> > for( sig = bo.GetFirstSignal( i ); sig; sig =
> bo.GetNextSignal( i ) )
> > {
> > Line = "<TR><TD>" + sig.Symbol + "</TD><TD>" +
> > DateTimeToStr( dt[ i ] ) + "</TD><TD>" + k +
> "</TD></TR>\n";
> > fputs( Line, fh );
> > k++;
> > }
> > }
> >
> > bo.PostProcess();
> >
> > fputs( "</TABLE>", fh );
> > fclose( fh );
> > }
> >
> >
> > Best regards,
> > Tomasz Janeczko
> > amibroker.com
> > ----- Original Message -----
> > From: Ken Close
> > To: amibroker@xxxxxxxxx <mailto:amibroker%40yahoogroups.com>
ps.com
> > Sent: Sunday, July 06, 2008 5:35 PM
> > Subject: [amibroker] Paul Ho: Memory Challenges with Great
> Ranking Tool
> >
> >
> > Paul:
> >
> > my initial euphoria has turned somewhat downward as I attempt to
> apply the code below (just two indicators) to larger Watchlists. You
> sounded (from other messages) like someone who knows the ins and
outs of
> memory management with AB, and perhaps can comment on how to keep
the code
> below from "bogging down".
> >
> > In spite of my many years with AB and its array processing, my
> mind still has a problem wrapping around what this code is doing
and why
> (and whether) larger populated Watchlists will ever be able to work.
> >
> > I initially tested against the DJ-30 (30 symbols) and all went
> well, fairly quickly, perhaps 10-15 seconds.
> >
> > I then tried the NDX (100 symbols) and things went more slowly
> but finished. I noticed the symbols appearing in the AA window more
slowly.
> >
> > I have not been able to nor wanted to wait for the SP-500, as
> the symbols appear more and more slowly and the est time counter
was saying
> something like 1 1/2 hours to complete 500 symbols.
> >
> > I was assuming that the code had to collect or process all
> symbols before it could make comparisons among them---this is
probably false
> or else why would processed symbols start to appear in the AA
window while
> it is still accessing symbols.
> >
> > What suggestions can you make, given your understanding of the
> code and AB, that would minimize the processing of large member
watchlists?
> >
> > Can adding a SetBarsRequired in the right place limit the number
> of lookback bars that are processed, and thus speed up execution?
> >
> > As the number of indicators I wish to process into a "Total
> Rank" score increases, I imagine that executing this code will get
slower
> and slower and may not be possible at all. Would you agree?
> >
> > Thanks for any added help.
> >
> > Ken
> >
> >
> >
> >
> ----------------------------------------------------------
> > From: amibroker@xxxxxxxxx <mailto:amibroker%40yahoogroups.com>
ps.com
> [mailto:amibroker@xxxxxxxxx <mailto:amibroker%40yahoogroups.com>
ps.com] On
> Behalf Of Ken Close
> > Sent: Saturday, July 05, 2008 10:47 AM
> > To: amibroker@xxxxxxxxx <mailto:amibroker%40yahoogroups.com>
ps.com
> > Subject: [amibroker] What a Great Ranking Tool
> >
> >
> > Paul Ho has come up with a supurb ranking tool. I have expanded
> it to two indicators. Feel free to expand the code structure to any
number
> of indicators.
> >
> > Possible next step: stick the Tot_Rank values into the OI field
> for the symbols, then Plot the Ranks for a visual representation
of "where
> the symbol is over time".
> >
> > The possibilities are endless (or at least enlarged because of
> Paul's code idea). Thanks Paul for your creative input.
> >
> > Ken
> >
> > // Ranking_Alt01.afl KSC 07/05/2008
> >
> > // Original code by Paul Ho, Amibroker list 07/05/2008
> >
> > // Modifications and expansions by Ken Close 07/05/2008
> >
> >
> >
> > // Will ordinal rank every symbol in watchlist for every bar.
> >
> >
> >
> >
> >
> > mOwnROC = ROC(C, 14);
> >
> > mOwnRSI = RSIa(C, 14);
> >
> > mRoc = 0;
> >
> > mRSI = 0;
> >
> > list = CategoryGetSymbols(categoryWatchlist, 16);
> >
> > ROCcount[0] = rocrank[0] = 0;
> >
> > RSIcount[0] = RSIrank[0] = 0;
> >
> > for(i = 0; (sym = StrExtract(list, i)) != ""; i++)
> >
> > {
> >
> > SetForeign(sym);
> >
> > mRoc = ROC(C, 14);
> >
> > mRSI = RSIa(C, 14);
> >
> > RestorePriceArrays();
> >
> > n = !IsNull(mRoc);
> >
> > m = !IsNull(mRSI);
> >
> > roccount += n;
> >
> > rsicount += m;
> >
> > rocrank = IIf(Nz(mRoc) > mOwnROC, Rocrank + n, rocrank);
> >
> > rsirank = IIf(Nz(mRsi) > mOwnRSI, Rsirank + m, rsirank);
> >
> > Totrank = rocrank + rsirank;
> >
> > }
> >
> > ROCn = ROC(C, 14);
> >
> > RSIn = RSIa(C, 14);
> >
> > Filter = 1;
> >
> > Buy = Sell = 0;
> >
> > AddColumn(ROCn, "ROCn",1.2);
> >
> > AddColumn(RSIn, "RSIn",1.2);
> >
> > AddColumn(mRoc, "MROC", 1.2);
> >
> > AddColumn(ROCrank, "ROCRank", 1.0);
> >
> > AddColumn(RSIrank, "rsirank",1.0);
> >
> > AddColumn(Totrank, "Totrank", 1.0);
> >
> >
> >
> > // To check the sorting, run on a watchlist, then click once on
> the date column,
> >
> > // Then shift click on one of the indicators, ie, RSIn, and you
> will see the
> >
> > // ordinal values in order.
> >
>
> ------------------------------------
>
> 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.amibroke <http://www.amibroker.com/devlog/> r.com/devlog/
>
> For other support material please check also:
> http://www.amibroke <http://www.amibroker.com/support.html>
> r.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/
|