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

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



PureBytes Links

Trading Reference Links




thanks Graham. 
 
I also found the description in the help file 
although BarCount is not defined in the help files. I use BarCount for all my 
loopings and I did not have any problems that I am aware of. 
 
Still, I would like to know how it is defined. In 
my chart clicking on the last bar, WriteVal(BarCount) prints 175. Then when I 
move the cursor to the first bar inside this chart it prints 299. Indeed I went 
back 124 bars since WriteVal(LastValue(BarIndex()); prints 2899 and 
WriteVal(BarIndex()); prints 2775. So it appears that this charts shows 124 
bars. How do I get the number 175 for WriteVal(BarCount) when I click on 
the last bar in the chart?
 
regards, Ed
 
 
<BLOCKQUOTE 
>
  ----- Original Message ----- 
  <DIV 
  >From: 
  <A title=gkavanagh@xxxxxxxxxxxxx 
  href="">Graham 
  To: <A title=amibroker@xxxxxxxxxxxxxxx 
  href="">amibroker@xxxxxxxxxxxxxxx 
  Sent: Saturday, October 25, 2003 11:29 
  AM
  Subject: RE: [amibroker] size of an array 
  in AFL?
  I recall some added rider to using Barcount when it was 
  introduced, I thinkyou had to turn off QuickAFL for Indicators in the 
  preferences, but I am notabsolutely certain of this.From the Help 
  filesBarCount constant gives the number of bars in array (such as 
  Close, High,Low, Open, Volume, etc). Array elements are numbered from 0 
  (zero) toBarCount-1. To get the first bar you can use array[ 0 ], to 
  get the last bar of arrayyou can use array[ BarCount - 1 ];For 
  example:Close[ 5 ];Represents the sixth element (bar) of the close 
  array.Close[ 0 ];Represents the very first available bar of the close 
  array.High[ BarCount - 1 ];Represents the last bar of High array. 
  This example illustrates the for statement:myema[ 0 ] = Close[ 0 
  ]; for( i = 1; i < BarCount; i++ ){  myema[ i ] = 0.1 * 
  Close[ i ] + 0.9 * myema[ i - 1 ];}Cheers,Graham<A 
  href="">http://groups.msn.com/ASXShareTrading<A 
  href="">http://groups.msn.com/FMSAustralia 
  -----Original Message-----From: Ed [mailto:pablito@xxxxxxx] Sent: 
  Saturday, 25 October 2003 5:16 PMTo: amibroker@xxxxxxxxxxxxxxxSubject: 
  Re: [amibroker] size of an array in AFL?to my knowledge: 
  LastValue(BarIndex()): gives the number of bars available for the 
  symbolBarIndex(): gives the bar number counting from the first bar 
  available forthe symbol.I'm a bit confused about BarCount though. 
  I always thought that BarCount:gives the number of bars inside an 
  indicator window. So the first bar showninside the window is bar-number 
  0.However, I put inside the indicator 
  builder:WriteVal(BarCount);WriteVal(LastValue(BarIndex());WriteVal(BarIndex());The 
  last 2 do as expected.  WriteVal(LastValue(BarIndex()); always gives 
  youthe total number of bars available for a symbol. WriteVal(BarIndex()); 
  givesyou the index of the bar and its output changes when you move the 
  cursorwith the amount of bars you move the cursor back.However 
  BarCount behaves differently. Actually if a symbol has 2900 
  barsWriteVal(BarCount); prints 2900 if you put the cursor on any bar if 
  you showALL data in the chart. If I put only 2 bars in a chart 
  WriteVal(BarCount);prints 52 when I put the curson on the second and last 
  bar.I played with it a little but did not find out yet exactly how 
  BarCount isdefined.Maybe somebody can enlighten me?Thanks, 
  Ed----- Original Message ----- From: Dave Merrill To: 
  amibroker@xxxxxxxxxxxxxxx Sent: Saturday, October 25, 2003 10:01 
  AMSubject: 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 
  toit, 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 ingeneral know how every 
  array was created, but it's less elegant and lessself 
  contained.daveI'm not sure how to answer this because it 
  depends on which array you arerefering too.Are you refering to a 
  stock data array of some description? If so you coulduse 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 - 
  1Regards,William 
  Peterswww.amitools.com-----Original Message-----From: 
  Dave Merrill [mailto:dmerrill@xxxxxxx]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, onlythat 
  works:      for(i=1; i<=array.length; i++) 
  {thanks,daveSend BUG REPORTS to 
  bugs@xxxxxxxxxxxxxSend SUGGESTIONS to 
  suggest@xxxxxxxxxxxxx-----------------------------------------Post 
  AmiQuote-related messages ONLY to: amiquote@xxxxxxxxxxxxxxx (Web page: <A 
  href="">http://groups.yahoo.com/group/amiquote/messages/)--------------------------------------------Check 
  group FAQ at:<A 
  href="">http://groups.yahoo.com/group/amibroker/files/groupfaq.html 
  Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service. 
  Yahoo! Groups SponsorADVERTISEMENTSend BUG 
  REPORTS to bugs@xxxxxxxxxxxxxSend SUGGESTIONS to 
  suggest@xxxxxxxxxxxxx-----------------------------------------Post 
  AmiQuote-related messages ONLY to: amiquote@xxxxxxxxxxxxxxx (Web page: <A 
  href="">http://groups.yahoo.com/group/amiquote/messages/)--------------------------------------------Check 
  group FAQ at:<A 
  href="">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@xxxxxxxxxxxxxSend SUGGESTIONS to 
  suggest@xxxxxxxxxxxxx-----------------------------------------Post 
  AmiQuote-related messages ONLY to: amiquote@xxxxxxxxxxxxxxx (Web page: <A 
  href="">http://groups.yahoo.com/group/amiquote/messages/)--------------------------------------------Check 
  group FAQ at: <A 
  href="">http://groups.yahoo.com/group/amibroker/files/groupfaq.html 
  Your use of Yahoo! Groups is subject to the <A 
  href="">Yahoo! Terms of Service. 







Yahoo! Groups Sponsor


  ADVERTISEMENT 









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 the Yahoo! Terms of Service.