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

Re: [amibroker] Re: A simple loop, but not so simple?



PureBytes Links

Trading Reference Links

Title: Re: [amibroker] Re: A simple loop, but not so simple?


The problem, imno, with Quick-AFL is that it is based based on the number of bars displayed (plus some). As brian suggests it would be nice if we had separate Quick-AFL rules/settings for calculations. In RT we often like to see the chart for entire day but need to calculate only on the last 15 bars or so. This is what the small loop below is used for. 


The burden of calculations is rarely a problem when dealing only with a single ticker. However when scanning hundreds of tickers in real time some, especially using Foreign() type functions, slow the system down to a crawl. A solution that I am testing right now, is to separate data for calculations from display memory. This can be done by copying tickers to static memory at startup, and update these arrays (shifting and adding a bar) only when a new bar is completed (once a second). At this time the advantages appear to be:


1) The static array length can be set using SetBarsRequired(). afaik, The length of Composites and/or Foreign()s cannot be controlled.

2) Array refreshes can be set to onc/sec, or less, instead of one for every quote. 

3) Data retrieval is 100-400 times faster than using Foreign() or Composites.


I watched The World is Flat yesterday and especially liked the rule that "if it can be done it has been done". So, will the person who is already using this technique, and has written functions (DLL) like CreateStaticTickers( WL ), RefreshStaticTickers( WL ), and UseStaticData( WL ) functions, please step forward?! btw, RestorePriceArrays() will restore the normal environment.


Best regards,

herman




Tuesday, July 14, 2009, 1:34:43 AM, you wrote:


>> //  Now the loop

>> end = SelectedValue(bi);

>> start = end-100;

>> for (i=start; i<=end; i++)

>> {

>> }

>> // NOTE - assumes at least the following

>> SetBarsRequired(100,0)


> I don't know if it is viable idea but I like the idea of processing any part

> of the array that is in current execution (full database array or QuickAFL

> specified array) anywhere,anytime without tripping over SetBarsRequired, or

> needing to specify SBR for a defined pane OR block of delineated code.


> Something like C(LastValue(BarIndex()) - 10) would perform the required

> exectution on the close for only the last 10 bars.


> It could apply in BT, or charts, where the LastValue(BarIndex()) puts the stake in the ground.


> This way we could shorten the bars being referenced when and where ever we

> like ... I guess it is our problem if, in some cases it actually slows down the execution.


> R language allows ragged arrays and also array indexing (subsections of an

> array), which seems to offer some advantages to time series analysis.


> KEYWORDS


> OPTIMAL RT PERFORMANCE


> --- In amibroker@xxxxxxxxxxxxxxx, "bruce1r" <brucer@xxx> wrote:


>> Herman -


>> Bottom line - do the following - explanation follows -


>> //  The following yields a QuickAFL array index

>> bi = BarIndex();

>> bi = bi - bi[0];


>> //  Now the loop

>> end = SelectedValue(bi);

>> start = end-100;

>> for (i=start; i<=end; i++)

>> {

>> }

>> // NOTE - assumes at least the following

>> SetBarsRequired(100,0)


>> To see how this works is a little tough without pictures, but envision

>> the following -


>>     * Ticker contains 5000 bars

>>     * Last 1000 bars displayed

>>     * SetBarsRequired(100,0) has been used

>> QuickAFL is going to present arrays as 1100 bars (1000 displayed+100

>> back).  The trick is that the BarIndex() function returns the bar index

>> for the full data.  So, it returns values 3900 - 4999 in the BarIndex()

>> array that you "see" in AFL.  You have to convert it to a QuickAFL index

>> that you can use for looping by subtracting the "bias amount" of the

>> first bar.


>> See Tomasz's much better explanation at -


>> http://www.amibroker.com/kb/index.php?s=quickafl


>> -- BruceR






> ------------------------------------


> **** 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


> <*> To visit your group on the web, go to:

>     http://groups.yahoo.com/group/amibroker/


> <*> Your email settings:

>     Individual Email | Traditional


> <*> To change settings online go to:

>     http://groups.yahoo.com/group/amibroker/join

>     (Yahoo! ID required)


> <*> To change settings via email:

>     mailto:amibroker-digest@xxxxxxxxxxxxxxx 

>     mailto:amibroker-fullfeatured@xxxxxxxxxxxxxxx


> <*> To unsubscribe from this group, send an email to:

>     amibroker-unsubscribe@xxxxxxxxxxxxxxx


> <*> Your use of Yahoo! Groups is subject to:

>     http://docs.yahoo.com/info/terms/





__._,_.___


**** 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/





Your email settings: Individual Email|Traditional
Change settings via the Web (Yahoo! ID required)
Change settings via email: Switch delivery to Daily Digest | Switch to Fully Featured
Visit Your Group | Yahoo! Groups Terms of Use | Unsubscribe

__,_._,___