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

RE: [amibroker] Re: size of an array in AFL?



PureBytes Links

Trading Reference Links

Dimitris,

DT Wrote:
"PS: Just curious, what is the use of this artificial array x you 
referred. Does it exist for some technical reason or it is just a 
theoretical construction ? "


Dave never mentioned what he is using this for.

Regards,
William Peters
www.amitools.com



-----Original Message-----
From: DIMITRIS TSOKAKIS [mailto:TSOKAKIS@xxxxxxxxx]
Sent: October 25, 2003 11:12 PM
To: amibroker@xxxxxxxxxxxxxxx
Subject: [amibroker] Re: size of an array in AFL?


William,
see my previous reply to Dave.
For your example
x[0]=1;x[1]=2;x[2]=2;x[3]=1;x[4]=3;
size1=Cum(IsTrue(x));
Plot(x,"x",4,1);
Plot(size1,"size1",1,1);
If you decide to count the empty/not defined bars, then the size is 
cum(1).
[Since we speak for "size", it is better to avoid the zero-basis 
counting.
For the array y with y[0]=100; the size is 1, if you use 0-basis 
counting, you should say the size is 0 which doesnt make any sense 
IMO].
In order to avoid theoretical discussions, we are interested here for 
amibroker arrays, plotted in our IB or explored with our AA. The size 
of an amibroker array is Cum(IsTrue(x)) or cum(1), according to your 
consideration for the empty/not defined bars.
Another tip will make things more clear: Suppose you have for your 
INTC 1000 OHLCV bars.
Well, select INTC and try the
x[0]=1;x[1]=2;x[2]=2;x[3]=1;x[4]=3;x[2000]=4;
You will immediately see 
Error 7.
Subscript out of range
The reason is simple:amibroker "knows" in advance the total INTC 
bars, which define the "range".
Dimitris Tsokakis
PS: Just curious, what is the use of this artificial array x you 
referred. Does it exist for some technical reason or it is just a 
theoretical construction ? 
Anyway, AFL can count even this...
--- In amibroker@xxxxxxxxxxxxxxx, "William Peters" 
<williampeters@xxxx> wrote:
> 
> I don't think you understood my reply.
> 
> I was not refering to the "stock arrays" or any array based on the 
stock arrays (which is what barcount is useful for). I was refering 
to an array constructed independantly of the stock arrays:
> 
> In the following example x contains three elements, how do we get 
the element count (in AFL) for x ?
> i.e.
> 
> x[0] = 1;
> x[1] = 2;
> x[2] = 3;
> 
> 
> In Visual Basic we can perform lbound(x) and ubound(x) which 
returns the lower and upper bounds of an array, in AFL I don't know 
of any function that performs a simular job (there maybe but I am 
unaware of them).
> 
> 
> Regards,
> William Peters
> www.amitools.com
> 
> 
> 
> -----Original Message-----
> From: DIMITRIS TSOKAKIS [mailto:TSOKAKIS@x...]
> Sent: October 25, 2003 7:15 AM
> To: amibroker@xxxxxxxxxxxxxxx
> Subject: [amibroker] Re: size of an array in AFL?
> 
> 
> --- In amibroker@xxxxxxxxxxxxxxx, "William Peters" 
> <williampeters@xxxx> wrote:
> > 
> > I don't believe the AFL has a function that returns the number of 
> elements
> > in an array.
> 
> William,
> AFL would be a miserable and unproductive language without counting 
> the elements of an array !! [I am curious if there exist any T/A 
> language without this property...]. I didn't understand your reply. 
> Dimitris Tsokakis
> > If you are constructing your own arrays as opposed to using the 
> stock arrays
> > I would simply maintain the element count within a variable.
> > As stated in the first post when you refer to elements in the 
stock 
> arrays
> > the first bar is 0 and the last bar is Barcount -1 (these arrays 
> are zero
> > based).
> > Regards,
> > William Peters
> > www.amitools.com
> > 
> > -----Original Message-----
> > From: Dave Merrill [mailto:dmerrill@x...]
> > Sent: October 25, 2003 1:02 AM
> > To: amibroker@xxxxxxxxxxxxxxx
> > Subject: RE: [amibroker] size of an array in AFL?
> > 
> > 
> > in most languages, it's possible to find out the size of an array 
> directly,
> > by examining some property of the array itself or applying some 
> function to
> > it, without having to know how it was created. some examples are:
> > 
> >     array.length
> >     array.size
> >     SizeOfArray(array)
> > 
> > is that possible in AFL? if not, it can be worked around since we 
> do in
> > general know how every array was created, but it's less elegant 
and 
> less
> > self contained.
> > 
> > dave
> > 
> >   I'm not sure how to answer this because it depends on which 
array 
> you are
> > refering too.
> > 
> >   Are you refering to a stock data array of some description? If 
so 
> you
> > could use the Barcount constant which will return the number of 
> bars in the
> > array. Remember it's zero based so the last bar is refered to as: 
> Barcount -
> > 1
> > 
> >   Regards,
> >   William Peters
> >   www.amitools.com
> > 
> > 
> > 
> >   -----Original Message-----
> >   From: Dave Merrill [mailto:dmerrill@x...]
> > 
> > 
> >   sorry for the dumb question, but what's the syntax for getting 
> the size
> >   (number of elements) in an array? I want to do something like 
> this, only
> >   that works:
> > 
> >         for(i=1; i<=array.length; i++) {
> > 
> >   thanks,
> > 
> >   dave
> > 
> >       Yahoo! Groups Sponsor
> >             ADVERTISEMENT
> > 
> > 
> > 
> > 
> > Send BUG REPORTS to bugs@xxxx
> > Send SUGGESTIONS to suggest@xxxx
> > -----------------------------------------
> > 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
> > 
> > Your use of Yahoo! Groups is subject to the Yahoo! Terms of 
Service.
> 
> 
> 
> Send BUG REPORTS to bugs@xxxx
> Send SUGGESTIONS to suggest@xxxx
> -----------------------------------------
> 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 
> 
> Your use of Yahoo! Groups is subject to 
http://docs.yahoo.com/info/terms/



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 

Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/ 



------------------------ Yahoo! Groups Sponsor ---------------------~-->
Buy Ink Cartridges or Refill Kits for your HP, Epson, Canon or Lexmark
Printer at MyInks.com. Free s/h on orders $50 or more to the US & Canada.
http://www.c1tracking.com/l.asp?cid=5511
http://us.click.yahoo.com/mOAaAA/3exGAA/qnsNAA/GHeqlB/TM
---------------------------------------------------------------------~->

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 

Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/