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

[amibroker] Re: JScripts - some debugging help needed



PureBytes Links

Trading Reference Links

There is one safe way to count stocks.
Scan all quotations with
AddToComposite(1,"~count","V");
Buy=0;
Plot(Foreign("~count","V"),"",4,8);
Your mycount plot from
 EnableScript("JScript");
 oAB = CreateStaticObject("Broker.Application");
 // NOTE FOLLOWING TWO LINES
 oStocks = oAB.Stocks();
 dummyResults = oStocks.DummyFunction();
 myVersion = oAB.Version();
 myCount = 0;
 <%
 ab = new ActiveXObject( "Broker.Application" );
AFL("myCount") = ab.Stocks().Count;
 %>
Plot(mycount,"",1,1);
is a flat line equal to the max number of stocks.
The problem begins when you want to use this mycount for various 
averages, it will be wrong for these bars with less stocks [for any 
reason].
Of course, in an absolutely aligned database it will be by 
coincidence correct and you will not have the opportunity to see the 
trap.
Unfortunately I have no idea of jscript and can not see what is wrong 
in your code.
Note also that the same mistake will come whan you use
list = CategoryGetSymbols( categoryWatchlist, 63 ); 
pop=0;
for( i = 0; ( sym = StrExtract( list, i ) ) != ""; i++ ) 
   {
pop=POP+1;
}
Plot(pop,"",5,2);
to plot the population pop of a WL63. The result will be a flat line, 
which is not correct when you have missing data, shorter or longer 
histories.
Dimitris Tsokakis

--- In amibroker@xxxxxxxxxxxxxxx, "jtelang" <jtelang@xxxx> wrote:
> Dimitris,
> 
> Yes, I see the count as the one returned by Stocks().Count method 
in 
> the AB ActiveX object. I verified it by running similar code 
outside 
> AA, from command line. The actual count I get in my case is 34,622 
> (with QP3). At the same time, if I run an explore against "All 
> Stocks/Last 1 bar", I get 26,819 entries in the result. That means 
> that around 8K symbols without any data (either on that last bar or 
> completely empty, I don't know) exist in the DB.
> 
> What count do you get when you run it?
> 
> Jitu
> 
> --- In amibroker@xxxxxxxxxxxxxxx, "DIMITRIS TSOKAKIS" 
<TSOKAKIS@xxxx> 
> wrote:
> > Jitu,
> > What is your mycount ?
> > Because it does not count the database stocks.
> > [Try to Plot(mycount,"",1,1); to see what I mean.]
> > Dimitris Tsokakis
> > > > -----Original Message-----
> > > > From: jtelang [mailto:jtelang@x...]
> > > > Sent: Wednesday December 31, 2003 12:14 AM
> > > > To: amibroker@xxxxxxxxxxxxxxx
> > > > Subject: [amibroker] Re: JScripts - some debugging help needed
> > > > 
> > > > 
> > > > William/Dingo,
> > > > 
> > > > Following line is a suspect -
> > > > 
> > > > >   oStocks = oAB.Stocks();
> > > > 
> > > > In AFL world, what are you expecting oStocks to be -- an AFL 
> > array, 
> > > a 
> > > > constant, a string or a JScript array of objects? I could be 
> > wrong, 
> > > > but I don't think you can treat such return values in pure 
AFL 
> > > world 
> > > > as if you were dealing with a JScript world. I'd think a more 
> > > > appropriate way to do it would be as follows, which does seem 
> to 
> > > > work -
> > > > 
> > > > // ------------
> > > > EnableScript("JScript");
> > > > oAB = CreateStaticObject("Broker.Application");
> > > > 
> > > > // NOTE FOLLOWING TWO LINES
> > > > oStocks = oAB.Stocks();
> > > > dummyResults = oStocks.DummyFunction();
> > > > 
> > > > myVersion = oAB.Version();
> > > > myCount = 0;
> > > > <%
> > > > ab = new ActiveXObject( "Broker.Application" );
> > > > AFL("myCount") = ab.Stocks().Count;
> > > > %>
> > > > Filter=1;
> > > > AddColumn(myCount, "Count");
> > > > AddTextColumn(myVersion,"Version");
> > > > // --------------
> > > > 
> > > > Also, note the two lines where marked. It seems on return 
> values 
> > > like 
> > > > oStocks, AB doesn't complain if it can't find the called 
> method. 
> > > > Actually I think that's going too far. AB doesn't probably 
even 
> > > know 
> > > > what type it is unless it can convert the original return 
value 
> > > > (oStocks) into an array, a constant or a string. But that's 
> just 
> > a 
> > > > guess. 
> > > > 
> > > > Hope this helps.
> > > > 
> > > > Jitu


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/