IMHO, it is not worth the effort, unless you are doing something _extremely_ 
complex.
AFL execution is just a fraction of total time, you would end up spending lots 
of time with very
little effect. Remember that your time is way more precious that CPU time.

Best regards,
Tomasz Janeczko
amibroker.com
----- Original Message ----- 
From: "Bisto" <[email protected]>
To: <[email protected]>
Sent: Tuesday, October 06, 2009 4:03 PM
Subject: [amibroker] Re: Tips for reducing CPU load


> Thanks TJ,
>
> your posts are always very instructive, it seems that you know well how AB 
> works :-)
>
> good to know that using static variables is the best way, I try to summarize:
>
> 1) to create static variables using a single pass of an AFL on a 
> symbol/watchlist, like an Explore with CreateStaticVariables.AFL
>
> 2) to optimize TradingSystem.AFL on the same symbol/watchlist who points to 
> the static variables created in point 1 who are 
> "alive" till overwritten or AB closed
>
> of course this is not the case of MA( C,15) but something a lot more complex
>
>
>
> --- In [email protected], "Tomasz Janeczko" <gro...@...> wrote:
>>
>> Hello,
>>
>> They are indeed recalculated when going through several backtests.
>> You could store such values in static variables and use them later in 
>> subsequent runs,
>> but it is in most cases _wasted_ effort, because array functions like MA( C, 
>> 15 ) are EQUALLY fast
>> as STATIC variables. This is so because static variables requires one pass 
>> any way (date/time synchronization)
>> the same as MA. MA can actually be slightly faster than static array 
>> variable because of locality of reference.
>>
>> Situation is different with normal variables (as I pointed out in my 
>> previous post), because normal variables
>> do not require synchronization (they are already in perfect sync) and do not 
>> require extra memory
>> nor ANY computation as they are simple POINTERS to values that were returned 
>> by function.
>> Storing/reading a pointer to array is a matter of single CPU instruction, 
>> i.e. is blazing fast (one CPU clock cycle).
>>
>> Regarding AddToComposite/Foreign - they are way slower than Static 
>> variables, so it makes no sense to use them for that purpose.
>>
>> Best regards,
>> Tomasz Janeczko
>> amibroker.com
>> ----- Original Message ----- 
>> From: "Bisto" <bistoma...@...>
>> To: <[email protected]>
>> Sent: Tuesday, October 06, 2009 1:52 PM
>> Subject: [amibroker] Re: Tips for reducing CPU load
>>
>>
>> >I was thinking about this issue yesterday and I have a question, please 
>> >correct me if I am wrong:
>> >
>> > During an optimization process there are so many repetitions of a function 
>> > with invariant parameter equal to the total number 
>> > of
>> > the steps of the optimization.
>> >
>> > In this case MA(C,15) will be calculated for every set of optimization 
>> > parameter even if it is invariant, OK?
>> >
>> > If we have a very time consuming invariant function in the TS it will be 
>> > calculated a lot of times even if it is not needed. 
>> > This
>> > is true if I have well interstood how AB works, please correct me
>> >
>> > my idea is to store this very time consuming invariant function in a 
>> > "fake" symbol (using Addtocomposite) and access to its 
>> > values
>> > by Setforeing.
>> >
>> > Is it a good idea?
>> >
>> > Bisto
>> >
>> > --- In [email protected], "Tomasz Janeczko" <groups@> wrote:
>> >>
>> >> Hello,
>> >>
>> >> For example, take a look at this simple code:
>> >>
>> >> Buy = Cross( MA(C, 5 ), MA( C, 15 ) );
>> >> Sell = Cross( MA( C, 15 ), MA( C, 5 ) );
>> >>
>> >> There are 2 repetitions of same function call with invariant parameters:
>> >> MA(C, 5 ) - is called twice
>> >> MA( C, 15 ) - is called twice
>> >>
>> >> This can be written in more efficient manner using variables:
>> >>
>> >> shortma = MA(C, 5 );
>> >> longma = MA( C, 15 );
>> >> Buy = Cross( shortma, longma );
>> >> Sell = Cross( longma, shortma );
>> >>
>> >> That is what I meant.
>> >>
>> >> Best regards,
>> >> Tomasz Janeczko
>> >> amibroker.com
>> >> ----- Original Message ----- 
>> >> From: "Rob" <sidhartha70@>
>> >> To: <[email protected]>
>> >> Sent: Tuesday, October 06, 2009 10:21 AM
>> >> Subject: [amibroker] Re: Tips for reducing CPU load
>> >>
>> >>
>> >> > TJ,
>> >> >
>> >> > Sorry my programming terminology is not as good as yours...
>> >> > What do you mean by 'replacing repeated function calls with invariant 
>> >> > parameters'...??
>> >> >
>> >> > --- In [email protected], "Tomasz Janeczko" <groups@> wrote:
>> >> >>
>> >> >> First and foremost: use AFL Editor, Tools->Code Check And Profile
>> >> >> to reduce complexity of your code, by removing repeated function calls 
>> >> >> (with invariant parameters),
>> >> >> using array operators wherever possible instead of loops,
>> >> >> re-thinking code to get simpler formulation,
>> >> >> avoiding any JScript/VBScript / COM objects in charts, etc.
>> >> >>
>> >> >> Best regards,
>> >> >> Tomasz Janeczko
>> >> >> amibroker.com
>> >> >> ----- Original Message ----- 
>> >> >> From: "Ara Kaloustian" <ara1@>
>> >> >> To: <[email protected]>
>> >> >> Sent: Tuesday, October 06, 2009 12:23 AM
>> >> >> Subject: Re: [amibroker] Tips for reducing CPU load
>> >> >>
>> >> >>
>> >> >> >- review your memory settings in preferences... make sure you are not
>> >> >> > allocating memory that you are not using
>> >> >> >
>> >> >> > - reduce number of symbols you monitor if you don't need them all
>> >> >> >
>> >> >> >
>> >> >> > ----- Original Message ----- 
>> >> >> > From: "Rob" <sidhartha70@>
>> >> >> > To: <[email protected]>
>> >> >> > Sent: Monday, October 05, 2009 2:33 PM
>> >> >> > Subject: [amibroker] Tips for reducing CPU load
>> >> >> >
>> >> >> >
>> >> >> >> Hi All,
>> >> >> >>
>> >> >> >> I seem to be maxing out the core I'm using on AB... starting to 
>> >> >> >> cause
>> >> >> >> problems operationally. I'm mainly doing charting and real time AFL.
>> >> >> >>
>> >> >> >> Any tips for reducing CPU load so I can perhaps give myself a 
>> >> >> >> little more
>> >> >> >> breathing space....??
>> >> >> >>
>> >> >> >> TIA
>> >> >> >>
>> >> >> >>
>> >> >> >>
>> >> >> >> ------------------------------------
>> >> >> >>
>> >> >> >> **** IMPORTANT PLEASE READ ****
>> >> >> >> This group is for the discussion between users only.
>> >> >> >> This is *NOT* technical support channel.
>> >> >> >>
>> >> >> >> TO GET TECHNICAL SUPPORT send an e-mail directly to
>> >> >> >> SUPPORT {at} amibroker.com
>> >> >> >>
>> >> >> >> TO SUBMIT SUGGESTIONS please use FEEDBACK CENTER at
>> >> >> >> http://www.amibroker.com/feedback/
>> >> >> >> (submissions sent via other channels won't be considered)
>> >> >> >>
>> >> >> >> For NEW RELEASE ANNOUNCEMENTS and other news always check DEVLOG:
>> >> >> >> http://www.amibroker.com/devlog/
>> >> >> >>
>> >> >> >> Yahoo! Groups Links
>> >> >> >>
>> >> >> >>
>> >> >> >>
>> >> >> >>
>> >> >> >
>> >> >> >
>> >> >> >
>> >> >> >
>> >> >> > ------------------------------------
>> >> >> >
>> >> >> > **** IMPORTANT PLEASE READ ****
>> >> >> > This group is for the discussion between users only.
>> >> >> > This is *NOT* technical support channel.
>> >> >> >
>> >> >> > TO GET TECHNICAL SUPPORT send an e-mail directly to
>> >> >> > SUPPORT {at} amibroker.com
>> >> >> >
>> >> >> > TO SUBMIT SUGGESTIONS please use FEEDBACK CENTER at
>> >> >> > http://www.amibroker.com/feedback/
>> >> >> > (submissions sent via other channels won't be considered)
>> >> >> >
>> >> >> > For NEW RELEASE ANNOUNCEMENTS and other news always check DEVLOG:
>> >> >> > http://www.amibroker.com/devlog/
>> >> >> >
>> >> >> > Yahoo! Groups Links
>> >> >> >
>> >> >> >
>> >> >> >
>> >> >>
>> >> >
>> >> >
>> >> >
>> >> >
>> >> > ------------------------------------
>> >> >
>> >> > **** IMPORTANT PLEASE READ ****
>> >> > This group is for the discussion between users only.
>> >> > This is *NOT* technical support channel.
>> >> >
>> >> > TO GET TECHNICAL SUPPORT send an e-mail directly to
>> >> > SUPPORT {at} amibroker.com
>> >> >
>> >> > TO SUBMIT SUGGESTIONS please use FEEDBACK CENTER at
>> >> > http://www.amibroker.com/feedback/
>> >> > (submissions sent via other channels won't be considered)
>> >> >
>> >> > For NEW RELEASE ANNOUNCEMENTS and other news always check DEVLOG:
>> >> > http://www.amibroker.com/devlog/
>> >> >
>> >> > Yahoo! Groups Links
>> >> >
>> >> >
>> >> >
>> >>
>> >
>> >
>> >
>> >
>> > ------------------------------------
>> >
>> > **** IMPORTANT PLEASE READ ****
>> > This group is for the discussion between users only.
>> > This is *NOT* technical support channel.
>> >
>> > TO GET TECHNICAL SUPPORT send an e-mail directly to
>> > SUPPORT {at} amibroker.com
>> >
>> > TO SUBMIT SUGGESTIONS please use FEEDBACK CENTER at
>> > http://www.amibroker.com/feedback/
>> > (submissions sent via other channels won't be considered)
>> >
>> > For NEW RELEASE ANNOUNCEMENTS and other news always check DEVLOG:
>> > http://www.amibroker.com/devlog/
>> >
>> > Yahoo! Groups Links
>> >
>> >
>> >
>>
>
>
>
>
> ------------------------------------
>
> **** IMPORTANT PLEASE READ ****
> This group is for the discussion between users only.
> This is *NOT* technical support channel.
>
> TO GET TECHNICAL SUPPORT send an e-mail directly to
> SUPPORT {at} amibroker.com
>
> TO SUBMIT SUGGESTIONS please use FEEDBACK CENTER at
> http://www.amibroker.com/feedback/
> (submissions sent via other channels won't be considered)
>
> For NEW RELEASE ANNOUNCEMENTS and other news always check DEVLOG:
> http://www.amibroker.com/devlog/
>
> Yahoo! Groups Links
>
>
>

Reply via email to