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

Re: [amibroker] Re: loop counter



PureBytes Links

Trading Reference Links

Hello,

> I was under the impression that QuickAFL loads bars depending 
> on what is needed to do the calculations in the code

Your impression was and is correct. But "what is needed to
do calcs" depends on zoom range, functions used, and other factors.

I explained it in more details on amibroke-beta list 3 years ago:
http://finance.groups.yahoo.com/group/amibroker-beta/message/1123

At the same time code can be executed many times in many
different contexts (for example tooltip, commentary, interpretation) and you should make
NO assumptions on how it is calculated.

Simply always loop from bar ZERO to (BarCount -1 ) bar.

Now BarIndex() is simply the original number of the bar in the
full data set. 

Again look in the docs:
http://www.amibroker.com/guide/afl/afl_view.php?barindex

Best regards,
Tomasz Janeczko
amibroker.com
----- Original Message ----- 
From: "wlandry01" <wlandry01@xxxxxxxxx>
To: <amibroker@xxxxxxxxxxxxxxx>
Sent: Wednesday, January 10, 2007 11:39 PM
Subject: [amibroker] Re: loop counter


> Terry,
> 
> Your code example illustrates on something that I do not 
> understand about QuickAFL.  It would seem to me that the line:
> 
> x = BarIndex();
> 
> would create an array containing a value for every bar in the
> database and that QuickAFL would, therefore, load all
> array values in order to perform the calculations.  As you noted,
> however, BarCount varies depending on the location in the
> chart, so some subset of the entire array is loaded.
> 
>, but
> it appears, instead, that what QuickAFL loads depends on the 
> location of the selection in the current chart view.  
> 
> Is that correct?  If so, are code statements re-evaluated based on
> the selection location in the chart each time the selection is
> reset?
> 
> Thanks,
> 
> 
> Wayne
> 
> 
> 
> --- In amibroker@xxxxxxxxxxxxxxx, "Terry" <MagicTH@xxx> wrote:
>>
>> BarCount does not necessarily == LastValue(BarIndex())
>> 
>> This is because Amibroker uses "quickAFL" which means it only uses
> enough
>> bars to "get the job done". This frequently is not all the bars.
>> 
>> --
>> Terry
>> 
>> -----Original Message-----
>> From: amibroker@xxxxxxxxxxxxxxx [mailto:amibroker@xxxxxxxxxxxxxxx]
> On Behalf
>> Of klaus_korneker
>> Sent: Wednesday, January 10, 2007 09:48
>> To: amibroker@xxxxxxxxxxxxxxx
>> Subject: [amibroker] Re: loop counter
>> 
>> Hi Terry,
>> 
>> thank you very much for your explanation !
>> However it looks a little bit strange. It works still the same.
>> When set the entire array to 0 with Cnt = 0; and click Apply, it shows
>> the same value as with the confirmation code in the graph. However 
>> automatically after about 1 second it changes the value to 199 instead
>> 4517
>> 
>> BTW: i know that it displays the number in the title based on my
> cursor. 
>> 
>> Regards
>> 
>> Klaus
>> 
>> 
>> --- In amibroker@xxxxxxxxxxxxxxx, "Terry" <MagicTH@> wrote:
>> >
>> > To initialize the loop you should do this:
>> > Cnt = 0; //Initializes entire array, not just 1st element.
>> > 
>> > When you click on the chart the number should change because you are
>> > selecting "that bar". Also see last paragraph about barcount.
> Otherwise,
>> > your loop is correct.
>> > 
>> > Here's some code to verify with:
>> > 
>> > x = BarIndex();
>> > Plot(x,"x",1,styleStaircase);
>> > NumToStr(BarCount,1.0);
>> > NumToStr(LastValue(BarIndex()),1.0);
>> > 
>> > Note the last two statements print in the interpretation window and
>> they are
>> > different because of quickAFL. The first changes with your selection
>> and the
>> > number of bars showing. The last does not change. It is the absolute
>> number
>> > of bars in your data. This is probably the reason your results are
>> changing
>> > in unexpected ways as you are using BarCount.
>> > --
>> > Terry
>> > 
>> > -----Original Message-----
>> > From: amibroker@xxxxxxxxxxxxxxx [mailto:amibroker@xxxxxxxxxxxxxxx]
>> On Behalf
>> > Of klaus_korneker
>> > Sent: Wednesday, January 10, 2007 07:43
>> > To: amibroker@xxxxxxxxxxxxxxx
>> > Subject: [amibroker] loop counter
>> > 
>> > Hello,
>> > 
>> > i am trying to build a counter with a loop. i have already tried the
>> > following, but it seems that anything is wrong. The chart shows the
>> > bar number, but when i click inside the chart, the number changes.
>> > 
>> > Cnt[0] = 0;
>> > for( i = 0; i < BarCount; i++ )
>> > { 
>> >     Cnt[ i ] = i ;
>> > } 
>> > 
>> > Graph0 = Cnt;
>> > 
>> > Thanks i advance !
>> > 
>> > 
>> > 
>> > 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 NEW RELEASE ANNOUNCEMENTS and other news always check DEVLOG:
>> > http://www.amibroker.com/devlog/
>> > 
>> > For other support material please check also:
>> > http://www.amibroker.com/support.html
>> >  
>> > Yahoo! Groups Links
>> >
>> 
>> 
>> 
>> 
>> 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 NEW RELEASE ANNOUNCEMENTS and other news always check DEVLOG:
>> http://www.amibroker.com/devlog/
>> 
>> For other support material please check also:
>> http://www.amibroker.com/support.html
>>  
>> Yahoo! Groups Links
>>
> 
> 
> 
> 
> 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 NEW RELEASE ANNOUNCEMENTS and other news always check DEVLOG:
> http://www.amibroker.com/devlog/
> 
> For other support material please check also:
> http://www.amibroker.com/support.html
> 
> Yahoo! Groups Links
> 
> 
> 
> 
>

Content-Description: "AVG certification"
No virus found in this incoming message.
Checked by AVG Free Edition.
Version: 7.5.432 / Virus Database: 268.16.9/622 - Release Date: 1/10/2007 2:52 PM