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

[amibroker] Re: some looping help needed .......



PureBytes Links

Trading Reference Links

Terry, I guess I can ask support specifically about the 
SetBarsRequired issue. I removed it and it seems to give the same 
results but also, it seems to take just as much time....  

May I ask: did you find time to look at the rest of the code? You 
see, if a more experienced coder could confirm that this is indeed 
the way to go (and I am not doing things unnecessarily complicated) 
that will give me some peace of mind and eventually make time-
consuming execution a bit more bearable.  

-treliff

--- In amibroker@xxxxxxxxxxxxxxx, "Terry" <MagicTH@xxxx> wrote:
> No, I'm not sure, but this has been discussed before. The last I 
recall
> Tomasz said not to use this anymore...but we're counting on 
my "recall"
> so that's not reliable ;-)
> 
> I do know that AB will use as many bars as necessary to get 
the "right"
> answer. It's very smart in that regard. Why don't you record some
> results, take out the SetBarsRequired and see if the answers are the
> same and if the speed is improved?
> --
> Terry
> 
> | -----Original Message-----
> | From: amibroker@xxxxxxxxxxxxxxx 
[mailto:amibroker@xxxxxxxxxxxxxxx] On
> | Behalf Of treliff
> | Sent: Tuesday, August 23, 2005 09:04
> | To: amibroker@xxxxxxxxxxxxxxx
> | Subject: [amibroker] Re: some looping help needed .......
> | 
> | Terry, no I don't need 100,000 bars (currently testing on several
> | years of daily bars) but I do want the calculation (standard
> | deviation) over all bars, so back to bar zero from any starting 
bar.
> | 
> | While AB Help menu says that SetBarsRequired is only necessary
> | outside pure AFL (having to do with "QuickAFL") I find many pure 
AFL
> | code examples that contain looping having this
> | 
> | setbarsrequired( 100000, 100000 ) // require all past and all 
future
> | bars
> | 
> | statement at the beginning (like in AFL library or in this forum).
> | 
> | Are you sure it can be left out?
> | 
> | I appreciate your help. Thanks.
> | 
> | -treliff
> | 
> | --- In amibroker@xxxxxxxxxxxxxxx, "Terry" <MagicTH@xxxx> wrote:
> | > Do you really need 100,000 bars to get the right answer?
> | > Seems like not forcing this many bars would speed things up a 
lot.
> | > --
> | > Terry
> | > | -----Original Message-----
> | > | From: amibroker@xxxxxxxxxxxxxxx
> | [mailto:amibroker@xxxxxxxxxxxxxxx] On
> | > | Behalf Of treliff
> | > | Sent: Monday, August 22, 2005 20:10
> | > | To: amibroker@xxxxxxxxxxxxxxx
> | > | Subject: [amibroker] some looping help needed .......
> | > |
> | > | Hoping for some help from Expert Coders.
> | > |
> | > | Code in question is part of a larger code and creates an
> | incredible
> | > | drag, slow chart scrolling etc., understandably so in view of 
the
> | > | amount of procedures. Hope this can be simplified/improved.
> | > | Appreciate anyone's time to take a look and possibly help me 
out.
> | > |
> | > | I have an array called "Cycle" that contains integers between
> | > | 10 and
> | > | 50.
> | > |
> | > | I have a function called "Oscillator" that, working on any
> | > | Cycle
> | > | array, returns some oscillator, meaning it is limited on up- 
and
> | > | downside and has Mean approximately zero (like an irregular
> | Sinus).
> | > |
> | > | My challenge is that once Cycle has been generated (earlier 
in my
> | > | code) I want to calculate the standard deviation of Oscillator
> | over
> | > | all previous bars using strictly the Cycle value of that
> | particular
> | > | Bar (not the Cycle array which has different values).
> | > |
> | > | For example:
> | > | - Bar 300 has cycle value 27
> | > | - I create an array with value "27" in all array elements
> | > | - then calculate Oscillator of this "27" array
> | > | - calculate the standard deviation of all Oscillator values 
up to
> | Bar
> | > | 300
> | > | - place this particular value in Bar 300 of a new array
> | > | - execute this procedure for all Bars separately
> | > |
> | > | Below is the code I made. TIA for any advice.
> | > |
> | > | // code start
> | > |
> | > | /* NOTE: the first few lines below are IRrelevant, only to 
create
> | > | random Cycle values between 10 and 50 and some Oscillator
> | function,
> | > | in order for the lower part to work */
> | > |
> | > | function Randomize(a,b)
> | > | { return Random(1)*(b-a)+a ; }
> | > |
> | > | Cycle = int( Randomize(10,50) ) ;
> | > |
> | > | function Oscillator(n)
> | > | { return Randomize(-50,n) ; }
> | > |
> | > | /* HERE starts the relevant part */
> | > |
> | > | SetBarsRequired( 100000, 100000 );
> | > |
> | > | function StDevCum(array)
> | > | { return sqrt( ( (BarIndex()+1) * Cum(array^2) - (Cum(array))
> | ^2 ) /
> | > | (BarIndex()+1)^2 ); }
> | > |
> | > | /* StDevCum calculates standard deviation of array from Bar 
zero
> | up
> | > | to current Bar. */
> | > |
> | > | function Cycleconstant(number)
> | > | { for ( i = 0 ; i < BarCount ; i++ )
> | > | { result[ i ] = Cycle[ number ] ; }
> | > |   return result; }
> | > |
> | > | /* Cycleconstant fills a complete array with a Cycle array 
element
> | > | value (number). */
> | > |
> | > | for (j = 0 ; j < BarCount ; j++ )
> | > | { y = StDevCum( Oscillator( Cycleconstant( j ) ) ) ;
> | > |   StDevCumOfOscillator[ j ] = y[ j ] ; }
> | > |
> | > | /* for each separate Bar this first works Oscillator on
> | Cycleconstant
> | > | array of that Bar, then calculates standard deviation (from 
Bar 0)
> | > | and places result in Bar value (array element) of new array
> | > | StDevCumOfOscillator. */
> | > |
> | > | Plot(0,"",colorBlack);
> | > | Plot(Oscillator(Cycle),"Oscillator(Cycle)",colorBlue);
> | > | Plot(StDevCumOfOscillator,"StDevCumOfOscillator",colorRed);
> | > | GraphZOrder = 1;
> | > |
> | > | // code end
> | > |
> | > |
> | > |
> | > |
> | > |
> | > | ------------------------ Yahoo! Groups Sponsor ---------------
----
> | -~--
> | > | >
> | > | <font face=arial size=-1><a
> | > |
> | 
href="http://us.ard.yahoo.com/SIG=12h0dd89q/M=362131.6882500.7825259.1
> | > |
> | 
493532/D=groups/S=1705632198:TM/Y=YAHOO/EXP=1124770234/A=2889190/R=0/S
> | > | IG=10r90krvo/*http://www.thebeehive.org
> | > | ">Put more honey in your pocket. (money matters made easy)
> | Welcome to
> | > | the Sweet Life - brought to you by One Economy</a>.</font>
> | > | --------------------------------------------------------------
----
> | --~-
> | > | >
> | > |
> | > | 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 other support material please check also:
> | > | http://www.amibroker.com/support.html
> | > |
> | > |
> | > | Yahoo! Groups Links
> | > |
> | > |
> | > |
> | > |
> | > |
> | 
> | 
> | 
> | 
> | 
> | ------------------------ Yahoo! Groups Sponsor -------------------
-~--
> | >
> | <font face=arial size=-1><a
> | 
href="http://us.ard.yahoo.com/SIG=12hhmiq6u/M=362131.6882500.7825259.1
> | 
493532/D=groups/S=1705632198:TM/Y=YAHOO/EXP=1124816731/A=2889190/R=0/S
> | IG=10r90krvo/*http://www.thebeehive.org
> | ">Put more honey in your pocket. (money matters made easy) 
Welcome to
> | the Sweet Life - brought to you by One Economy</a>.</font>
> | ------------------------------------------------------------------
--~-
> | >
> | 
> | 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 other support material please check also:
> | http://www.amibroker.com/support.html
> | 
> | 
> | Yahoo! Groups Links
> | 
> | 
> | 
> |




------------------------ Yahoo! Groups Sponsor --------------------~--> 
<font face=arial size=-1><a href="http://us.ard.yahoo.com/SIG=12h0rqp9k/M=362343.6886682.7839641.1493532/D=groups/S=1705632198:TM/Y=YAHOO/EXP=1124819630/A=2894352/R=0/SIG=11fdoufgv/*http://www.globalgiving.com/cb/cidi/tsun.html";>Help tsunami villages rebuild at GlobalGiving. The real work starts now</a>.</font>
--------------------------------------------------------------------~-> 

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 other support material please check also:
http://www.amibroker.com/support.html

 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/amibroker/

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