Calling only once means assign the variable a name i.e. k = AFLfunction(x,y,z); Thereafter refer to the value k instead of repeating the calls in other locations. Example: instead of A = C + StdDev(C,n); B = C - StdDev(C,n); Use: S = StdDev(C,n); //call the function once and use below A = C + S; B = C - S;
Joseph Biran ____________________________________________ -----Original Message----- From: [email protected] [mailto:[EMAIL PROTECTED] On Behalf Of js8765 Sent: Sunday, May 11, 2008 3:23 PM To: [email protected] Subject: Re: [amibroker] How To Restore Formula Speed? How do you call a function once using AFL? If I look at the section "Understanding how AFL works" that is always quoted whenever anyone has questions about the hard to grasp array processing language, I can't see anything about how to call a function once... Thanks for any help. P.S. Tomasz, everything is always easy when you know how. What maybe is a bit more difficult is to put yourself in the position of others who are still learning and understand that it is not so easy... Tomasz Janeczko wrote: > Percentile involves sorting, it is currently implemented > using absolutely the fastest algorithm known to human kind. > > What you can do to speed it up - that's easy - call it once > and store result. > This (calling same functions with same arguments many times instead calling it once) > is the most common mistake people are making. > > > Best regards, > Tomasz Janeczko > amibroker.com > ----- Original Message ----- > From: Louis Préfontaine > To: [email protected] > Sent: Sunday, May 11, 2008 4:15 PM > Subject: Re: [amibroker] How To Restore Formula Speed? > > > Hi Tomasz, > > Is there a way to speed up Percentile function? > > Thanks, > > Louis > > > 2008/5/11 Tomasz Janeczko <[EMAIL PROTECTED]>: > > Hello, > > Use > AFL Editor, > Tools->Check and Profile > to find the bottleneck in your code. > > Most often people are > calling the same funciton over and over many times when > they should call it ONCE and store the result in variable. > This the most basic improvement can be applied to 99% of > formulas written and posted here to get a lot more speed. > The other thing is that you move all array function calls OUTSIDE > loops. That's second principle: *never* call array function > inside loop , unless you are doing something like iterating > through multiple symbols. But NEVER call array funcitons > inside per-bar loop. > > Best regards, > Tomasz Janeczko > amibroker.com > > > ----- Original Message ----- > From: "ondrej.uhlarik" <[EMAIL PROTECTED]> > To: <[email protected]> > Sent: Sunday, May 11, 2008 2:44 PM > Subject: [amibroker] How To Restore Formula Speed? > > > Hello, > > I have programed quite a complicated indicator in AFL. When I load it > > in a pane it significantly slows down scrolling speed and reaction > > speed in general. That I find very annoying, so I made a Toggle > > parameter to switch between 2 modes: Basic (which does not show so much > > but does not affect speed so much either) and Advanced (which shows > > everything and affects speed a lot). Now the problem is as follows: > > I insert the indicator in a pane in the Basic mode and the speed is ok. > > Then I switch to the Advanced mode and the speed gets worse. Then I > > switch back to the Basic mode but the speed remains bad, i.e. the > > original speed is not restored. It seems that the Advanced data are > > still loaded in some memory cache and affect speed of the indicator > > even if I switch back to the Basic mode. Is there any chance to clear > > or reset the data loaded in memory (or whatever) without removing the > > indicator from the pane and re-inserting it back? > > Thank you for your ideas, and please keep in mind that I am a beginner > > in programing :)
