Tomasz,

You need to read the rest of the thread. The exercise was *specifically* to 
empty and populate a watchlist using *JScript*.

This is just one example showing that the OLE API is becoming out of date. It 
would be nice to see some additional attention given to this area in a future 
release.

Mike

--- In amibroker@yahoogroups.com, Tomasz Janeczko <gro...@...> wrote:
>
> Hello,
> 
> Wrong! WatchListBits is obsolete and is provided *only* for backward 
> compatibility
> and works ONLY for first 64 watch lists.
> 
> There are now *native* AmiBroker functions for adding/removing symbols
> not only to watch lists but to *any* kind of category (including of 
> course watch lists).
> 
> When everything fails, read the manual.
> 
> http://www.amibroker.com/f?categoryaddsymbol
> http://www.amibroker.com/f?categoryremovesymbol
> 
> Best regards,
> Tomasz Janeczko
> amibroker.com
> 
> 
> On 2009-11-30 18:44, bistrader wrote:
> > Yep, got it.  Nice explanation.  Something you did not have to do!  Thanks 
> > again!!
> >
> > --- In amibroker@yahoogroups.com, "Mike"<sfclimbers@>  wrote:
> >    
> >> Let me prefix my comments by saying that there may be a more efficient way 
> >> of doing it.
> >>
> >> I did not see any obvious OLE access for watchlists. However, there is 
> >> access to the stocks in the database. Part of that stock access includes a 
> >> bit field for which watchlists the stock belongs to.
> >>
> >> Therefore, to empty the watchlist we could iterate through the universe of 
> >> stocks and remove each from the target watchlist by clearing (i.e. setting 
> >> to 0) the bit identifying the target watchlist. In the world of bitwise 
> >> manipulation, you can clear a bit by "and-ing" it with 0 (i.e. false) 
> >> since anything "and false" will always be false as a whole.
> >>
> >> Similarly, to add all stocks to the watchlist, we could iterate through 
> >> the universe of stocks and set (i.e. change to 1) the bit for the target 
> >> watchlist. In the world of bitwise manipulation, you can set a bit by 
> >> "or-ing" it with 1 (i.e. true) since anything "or true" will always be 
> >> true as a whole.
> >>
> >> Combining the two approaches, a single loop can be employed to either set 
> >> or clear the watchlist bit based on the desirability of the stock being 
> >> considered. Thus leaving the only question to be which stocks to include?
> >>
> >> In your case the answer is those stocks found in your .csv file.
> >>
> >> Approach 1.
> >> Using a single iteration through the universe of database stocks, we could 
> >> have searched for each stock in your file, and upon finding the stock set 
> >> it's watchlist bit, else cleared it's watchlist bit. But, if there were 
> >> 'n' stocks in the database, that would mean n searches of your .csv file. 
> >> File manipations are not cheap.
> >>
> >> Approach 2.
> >> Alternatively, we could have done an initial sweep of the universe of 
> >> database stocks to clear the bit for all of them. Then done a single 
> >> iteration of your .csv file and for each stock compared it to every stock 
> >> in the database until we found the match, at which point we would set the 
> >> bit for that database stock. But, if there were 'n' stocks in your 
> >> watchlist, we would have done at least a partial iteration through the 
> >> database of stocks n+1 times (once to clear all, then n more times up 
> >> until each stock was found).
> >>
> >> Assuming that searching a string is less expensive than searching line by 
> >> line through a file, I instead constructed a single string prefixed with a 
> >> comma, followed by a comma separated list of all the stocks in your .csv 
> >> file, and suffixed with a comma.
> >>
> >> e.g.
> >> ",ORCL,IBM,AAPL,"
> >>
> >> Now, using Approach 1 above, we can simply search the string instead of 
> >> searching your .csv file. Since there may be overlap between stock names 
> >> (e.g. A and AA), we rely on the commas as delimeters for complete names 
> >> and search for ",A," and ",AA," respectively.
> >>
> >> Make sense?
> >>
> >> Mike
> >>
> >> --- In amibroker@yahoogroups.com, "bistrader"<bistrader@>  wrote:
> >>      
> >>> Thanks Mike.  I did each, will do more and give it a try.  I am sure I 
> >>> will get it,  Today, I do not totally understand exactly what the 
> >>> following code you provided is doing.  It seems to be comparing 2 strings 
> >>> by looping thru all stocks in the database.  I have read via google and 
> >>> am not clear.
> >>>
> >>>     for (j = 0; j<  count; j++) {
> >>>        stock = stocks.Item(j);
> >>>
> >>>        if (tickers.indexOf("," + stock.Ticker + ",")>= 0) {
> >>>           stock.WatchListBits |= 1<<  20;      // Add to watchlist 20
> >>>        } else {
> >>>           stock.WatchListBits&= !(1<<  20);   // Remove from watchlist 20
> >>>        }
> >>>
> >>>
> >>>
> >>> --- In amibroker@yahoogroups.com, "Mike"<sfclimbers@>  wrote:
> >>>        
> >>>> Microsoft's MSDN has good coverage for much of what is available.
> >>>>
> >>>> e.g. file usage:
> >>>> http://msdn.microsoft.com/en-us/library/czxefwt8(VS.85).aspx
> >>>>
> >>>> They also have an area dedicated to JScript, which I haven't sifted 
> >>>> through yet.
> >>>>
> >>>> http://msdn.microsoft.com/en-us/library/4yyeyb0a(VS.85).aspx
> >>>>
> >>>> Whenever I need something, I just google for an english description of 
> >>>> what I want, like "how to ... in JScript". You usually end up wading 
> >>>> through a bunch of javascript web development specific stuff. But, 
> >>>> eventually you hit a JScript example in a user forum somewhere.
> >>>>
> >>>> Mike
> >>>>
> >>>> --- In amibroker@yahoogroups.com, "bistrader"<bistrader@>  wrote:
> >>>>          
> >>>>> Mike, I did not see this and do not know how I missed it.  I studied.  
> >>>>> I understand all of the basic code and loop.  I do not understand first 
> >>>>> 4 lines and will do google search on these.  Maybe you or someone else 
> >>>>> has a good site or document to go to, to do better job at JavaScript.  
> >>>>> Thanks so much for your help.
> >>>>>
> >>>>> --- In amibroker@yahoogroups.com, "Mike"<sfclimbers@>  wrote:
> >>>>>            
> >>>>>>
> >>>>>> I believe that the following will serve as a skeleton for the desired
> >>>>>> steps 1, 2, 5.
> >>>>>>
> >>>>>> fso = new ActiveXObject("Scripting.FileSystemObject");
> >>>>>> ab = new ActiveXObject("Broker.Application");
> >>>>>> stocks = ab.Stocks;
> >>>>>> count = stocks.Count;
> >>>>>> aa = ab.Analysis;
> >>>>>>
> >>>>>> for (i = 1; i<= 10; i++) {
> >>>>>>      f = fso.GetFile("c:\\temp\\Input" + i + ".csv");
> >>>>>>      ts = f.OpenAsTextStream(1, 0);  // Open for read of ASCII
> >>>>>>      tickers = ",";
> >>>>>>
> >>>>>>      while (!ts.AtEndOfStream) {
> >>>>>>         tickers += ts.ReadLine();   // Assume one ticker per line in 
> >>>>>> .csv
> >>>>>> file
> >>>>>>         tickers += ",";
> >>>>>>      }
> >>>>>>
> >>>>>>      ts.Close();
> >>>>>>
> >>>>>>
> >>>>>>      for (j = 0; j<  count; j++) {
> >>>>>>         stock = stocks.Item(j);
> >>>>>>
> >>>>>>         if (tickers.indexOf("," + stock.Ticker + ",")>= 0) {
> >>>>>>            stock.WatchListBits |= 1<<  20;      // Add to watchlist 20
> >>>>>>         } else {
> >>>>>>            stock.WatchListBits&= !(1<<  20);   // Remove from watchlist
> >>>>>> 20
> >>>>>>         }
> >>>>>>      }
> >>>>>>
> >>>>>>      ab.RefreshAll();
> >>>>>>
> >>>>>>      // Your backtest here.
> >>>>>>      // Your exploration here.
> >>>>>> }
> >>>>>>
> >>>>>> Mike
> >>>>>>
> >>>>>>
> >>>>>> --- In amibroker@yahoogroups.com, "bistrader"<bistrader@>  wrote:
> >>>>>>              
> >>>>>>> I am working on a second JavaScript that I will post when done. I want
> >>>>>>>                
> >>>>>> it to do the following.
> >>>>>>              
> >>>>>>> 1. Makes watchlist 20 empty.
> >>>>>>> 2. Reads Input1.csv symbols into watchlist 20.
> >>>>>>> 3. Runs a backtest on MyBacktest.afl with filter at watchlist 20.
> >>>>>>> 4. Then, runs an exploration on MyExploration.afl using current symbol
> >>>>>>>                
> >>>>>> loaded in AB. This exploration creates a text file called Output1.csv 
> >>>>>> to
> >>>>>> match up with Input1.csv
> >>>>>>              
> >>>>>>> 5. Loops thru Step 1 thru Step4 for a total of 10 times starting with
> >>>>>>>                
> >>>>>> Input1.csv and ending with Input10.csv. In the end, there are
> >>>>>> Output1.csv thru Output10.csv.
> >>>>>>              
> >>>>>>> I know how to do Steps 3 and 4. I do not know as of yet how to do
> >>>>>>>                
> >>>>>> Steps 1, 2 and 5 in JavaScript. Help is appreciated and thanks!!
> >>>>>>              
> >>>>>>> Bert
> >>>>>>>
> >>>>>>>                
> >>>>>>              
> >>>>>            
> >>>>          
> >>>        
> >>      
> >
> >
> >
> > ------------------------------------
> >
> > **** IMPORTANT PLEASE READ ****
> > This group is for the discussion between users only.
> > This is *NOT* technical support channel.
> >
> > TO GET TECHNICAL SUPPORT send an e-mail directly to
> > SUPPORT {at} amibroker.com
> >
> > TO SUBMIT SUGGESTIONS please use FEEDBACK CENTER at
> > http://www.amibroker.com/feedback/
> > (submissions sent via other channels won't be considered)
> >
> > For NEW RELEASE ANNOUNCEMENTS and other news always check DEVLOG:
> > http://www.amibroker.com/devlog/
> >
> > Yahoo! Groups Links
> >
> >
> >
> >
> >
>


Reply via email to