No, NO NO! You should NEVER EVER be doing ANY extra stuff like that because AmiBroker does that FOR YOU AUTOMATICALLY by means of QuickAFL. It uses visible bars automatically.
Read THIS: http://www.amibroker.com/kb/2008/07/03/quickafl/ Best regards, Tomasz Janeczko amibroker.com ----- Original Message ----- From: "Mike" <[EMAIL PROTECTED]> To: <[email protected]> Sent: Saturday, November 29, 2008 6:39 AM Subject: [amibroker] Re: how to improve loop speed > Hi, > > Is this what you are looking for? > > firstVisibleBar = Status("FirstVisibleBar"); > lastVisibleBar = Status("LastVisibleBar"); > > for (bar = firstVisibleBar; bar <= lastVisibleBar; bar++) { > // Your code here... > } > > Mike > > --- In [email protected], "Panos Boufardeas" <[EMAIL PROTECTED]> > wrote: >> >> Hi >> Today I was playing without fully understanding what I was doing > and >> I believe I made a break through. >> Any way what I found is if I use >> for(i = 0; i < BarCount; i++ ) >> the results are 3446 data bars used during this check. Total >> execution time was 0.0228476 sec. >> >> and If I use >> for(i=BarCount-1;i>1 AND Status("firstvisiblebar");i--) >> The results are 3446 data bars used during this check. Total >> execution time: 0.00249557 sec. >> >> so the second loop looks faster. >> I would like to ask one more time what can I write to use just the >> visible bars? Is this possible? I am trying to find a way to speed > up >> the loops in codes that require them ,and to count just the visible >> bars or as less as possible. >> >> Thank you >> Panos >> >> --- In [email protected], "Panos Boufardeas" <panosbouf@> >> wrote: >> > >> > Thank you Tomasz >> > >> > So what I can see from your reply, this example here is correct. >> > But must be a way for a loop to calculate only the last X bars, > and >> > not all of theme >> > >> > Thank you >> > Panos >> > >> > --- In [email protected], "Tomasz Janeczko" <groups@> >> > wrote: >> > > >> > > Hello, >> > > >> > > Move ALL array functions OUTSIDE of loop! >> > > >> > > Inside the loop there should be only NON-array functions. >> > > >> > > >> > > // THIS MUST BE OUTSIDE THE LOOP !!!!!! >> > > >> > > Q=Param( "% Change",1.50,.25,14 ,0.25); >> > > >> > > Z= Zig(C,q ) ; >> > > >> > > HH=((Z<Ref(Z,- 1) AND Ref(Z,-1) > Ref(Z,-2)) AND (Peak(z,q,1 ) >> > > >> > > >Peak(Z,q,2 ))); >> > > >> > > LL=((Z>Ref(Z,- 1) AND Ref(Z,-1) < Ref(Z,-2)) AND (Trough > (Z,q,1 ) >> > <Trough(Z,q,2 ))); >> > > >> > > >> > > dist = 0.5*ATR (20); >> > > >> > > >> > > for( i = 0; i < BarCount; i++ ) >> > > { >> > > >> > > // ONLY THIS should be inside the loop >> > > if( HH [i]) PlotText( "HH"+ "\n"+H[ i ], i, H[ i ]+dist[i], >> > colorGreen ); >> > > if( LL [i] ) PlotText( ""+L[ i ]+"\nLL", i, L[ i ]-dist[i], >> > colorRed ); >> > > } >> > > >> > > Nothing more is needed. >> > > >> > > Best regards, >> > > Tomasz Janeczko >> > > amibroker.com >> > > ----- Original Message ----- >> > > From: "Panos Boufardeas" <panosbouf@> >> > > To: <[email protected]> >> > > Sent: Thursday, November 27, 2008 6:45 PM >> > > Subject: [amibroker] how to improve loop speed >> > > >> > > >> > > >> > > >> > > Hi >> > > >> > > I am curious to find out how to make a loop to run from >> > firstvisiblebar >> > > >> > > >> > > I think I need to write something like the following . but I >> don't >> > know how >> > > >> > > >> > > lvb = Status("lastvisiblebar"); >> > > >> > > fvb = Status("firstvisiblebar"); >> > > >> > > >> > > for( i = 0; i < ??? ; i++ ) >> > > >> > > { >> > > >> > > >> > > I have an example here that executes very slowly in live intra >> day >> > chart >> > > >> > > Can you tell me please how I can correct this example ? >> > > >> > > >> > > Q=Param( "% Change",1.50,.25,14 ,0.25); >> > > >> > > Z= Zig(C,q ) ; >> > > >> > > HH=((Z<Ref(Z,- 1) AND Ref(Z,-1) > >> > > >> > > Ref(Z,-2)) AND (Peak(z,q,1 ) >> > > >> > > >Peak(Z,q,2 ))); >> > > >> > > LL=((Z>Ref(Z,- 1) AND Ref(Z,-1) < Ref(Z,-2)) AND (Trough(Z,q,1 ) >> > > >> > > <Trough(Z,q,2 ))); >> > > >> > > >> > > dist = 0.5*ATR (20); >> > > >> > > >> > > for( i = 0; i < BarCount; i++ ) >> > > >> > > { >> > > >> > > if( HH [i]) PlotText( "HH"+ "\n"+H[ i ], i, H[ i >> > > >> > > ]+dist[i], colorGreen ); >> > > >> > > if( LL [i] ) PlotText( ""+L[ i ]+"\nLL", i, L[ i >> > > >> > > ]-dist[i], colorRed ); >> > > >> > > } >> > > >> > > >> > > Plot(C,"",IIf(C>O,colorGreen,colorRed),styleCandle); >> > > >> > > >> > > Thank you >> > > >> > > Panos >> > > >> > > >> > > >> > > >> > > >> > >> > > > > ------------------------------------ > > **** IMPORTANT **** > This group is for the discussion between users only. > This is *NOT* technical support channel. > > ********************* > TO GET TECHNICAL 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 > > >
