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

RE: [amibroker] Simple code stumper



PureBytes Links

Trading Reference Links

Bill,

 

I thought about this some more and decided to write further…

 

I believe what is happening is that your code is actually using three loops, not two.   The third loop is the one that we forget about – the scan itself.  The scan loops through each symbol in the source list (Watchlist, group, etc.) and processes it.  This includes running your deletion code multiple times – once for each symbol.

 

Here is the process (I think):

 

  1. You start your scan.
  2. The scan retrieves symbol 1 and starts processing it.
  3. It hits your cleanup code, which loops through the Watchlists merrily deleting all symbols.
  4. Then it finishes processing Symbol 1 and stuffs it into Watchlists.
  5. The scan retrieves symbol 2 and starts processing it.
  6. Then it runs your cleanup code again which zaps all of the Watchlist symbols again – including symbol 1 which was just stuffed in during the prior scan loop.
  7. Then, it finishes processing symbol 2 and stuffs it into Watchlists.
  8. The scan retrieves symbol number 3, zaps symbol number 2, and stuffs symbol 3 into Watchlists.
  9. So over and over the scan retrieves a symbol, deletes the prior symbol (actually all symbols) from the Watchlists, and stuffs the current one into Watchlists until the scan finishes.

 

So the reason that you have only one symbol is that each loop of your scan deletes all symbols before processing the current symbol.   What is different between your scan and mine (which I got from Tomasz) is that mine deletes only the current symbol from Watchlists.  

 

This was a revelation for me that I only fully understood (I think) in the last few days.

 

I hope this helps.  If anyone sees something wrong with my explanation, please jump in!

 

Regards,

 

Dan.


From: amibroker@xxxxxxxxxxxxxxx [mailto:amibroker@xxxxxxxxxxxxxxx] On Behalf Of wavemechanic
Sent: Sunday, August 14, 2005 9:33 PM
To: amibroker@xxxxxxxxxxxxxxx
Subject: Re: [amibroker] Simple code stumper

 

Dan:

 

I'm afraid that you are right.  A bit of a pain to be sure.

 

Bill

----- Original Message -----

From: Dan Clark

Sent: Sunday, August 14, 2005 11:39 PM

Subject: RE: [amibroker] Simple code stumper

 

Bill,

 

I don’t think that will work.  I tried something similar.   Try this:

 

/*

** Filter by Master List in AA Window

*/

 

//Remove current symbol from target Watchlist. 

//This ensures that <TargetWatchlist> is always clean.

CategoryRemoveSymbol("", categoryWatchlist, 1);  

CategoryRemoveSymbol("", categoryWatchlist, 2);  

CategoryRemoveSymbol("", categoryWatchlist, 3);  

CategoryRemoveSymbol("", categoryWatchlist, 4);  

CategoryRemoveSymbol("", categoryWatchlist, 5);  

CategoryRemoveSymbol("", categoryWatchlist, 6);  

CategoryRemoveSymbol("", categoryWatchlist, 7);  

CategoryRemoveSymbol("", categoryWatchlist, 8);  

 

Ensure that the AA filtering is such that your scan will include all symbols that could possibly be in any of your target Watchlists.   What happens is that, as each symbol is scanned, it is removed from each of the target Watchlists. 

 

This should run pretty fast.  It turns out that retrieving symbols is the slow part.  Once a symbol is retrieved and current, it will process pretty fast.  You should see little difference in removing a symbol from one Watchlist or eight Watchlists.

 

Regards,

 

Dan.

 


From: amibroker@xxxxxxxxxxxxxxx [mailto:amibroker@xxxxxxxxxxxxxxx] On Behalf Of wavemechanic
Sent: Sunday, August 14, 2005 7:54 PM
To: AmiBroker, User
Subject: Re: [amibroker] Simple code stumper

 

Dan:

 

Thanks.  I believe I see what you are doing and may have to go that route (kicking and screaming!).

 

What I am doing (and would like to continue doing) is simply using the settings in AA to define a group that acts as the filter for the ALL section.  My results are automatically sent to 8 watchlists and the CategoryAddSymbol() used to do this writes to the watchlists, but it does it in append mode.

 

I have used the following code that is similar to yours (I think) at the beginning of the program to cleanout the watchlist before writing the symbol results.  Unfortunately it does not work right and I don't know why.  It properly deletes old symbols but then does not allow results (except one) to be written to the watchlist.

 

All that is needed is a switch for CategoryAddSymbol() that permits overwriting rather than appending.  Hopefully, this is being considered for a future release.  As a friend from Ukraine says "Why simple if complex will work just as well." ;-)

 

Bill

==========================

 

for(i = 0; i < 8; i++)

{

list = CategoryGetSymbols(categoryWatchlist, i);

for(j = 0; (symbol = StrExtract(list, j)) != ""; j++)

{

    CategoryRemoveSymbol(symbol, categoryWatchlist, i);

}

}

----- Original Message -----

From: Dan Clark

Sent: Sunday, August 14, 2005 7:55 PM

Subject: RE: [amibroker] Simple code stumper

 

Bill,

 

I think I had the same issue a few days ago.  Tomasz suggested adding “CategoryRemoveSymbol()” to my code, but it is the flow of code that makes it work…

 

You use two source Watchlists. The first is a “Master” list of all the symbols you would trade.  (In my case, I call this “Tradable Symbols”.)  The second is one of several “Source” Watchlists.     

 

You always use the “Master” Watchlist as the Exploration filter.   Because you are always running through your Master, all symbols will be removed from the target Watchlist just prior to processing that symbol.

 

Your “Source” Watchlist is used by the “InWatchList” function.  If “InWatchList” is True, then process the symbol.  For example:

 

/*

** Filter by Master List in AA Window

*/

 

//Remove current symbol from target Watchlist. 

//This ensures that <TargetWatchlists> is always clean.

CategoryRemoveSymbol("", categoryWatchlist, <TargetWatchlist>);  

 

//Use InWatchlist to check for symbol in Source List

ValidSymbol = InWatchList ("", categoryWatchlist, <TargetWatchlist>);  

 

If (ValidSymbol)

  {

  // Your processing code here

  }

 

I think it would be a more elegant solution to be able to clean out the target Watchlist, but this works well.  I hope it works for you.

 

Regards,

 

Dan.

 


No virus found in this incoming message.
Checked by AVG Anti-Virus.
Version: 7.0.338 / Virus Database: 267.10.8/71 - Release Date: 08/12/05




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 other support material please check also:
http://www.amibroker.com/support.html





SPONSORED LINKS
Investment management software Investment property software Investment software
Investment tracking software Return on investment software Stock investment software


YAHOO! GROUPS LINKS