PureBytes Links
Trading Reference Links
|
Is that really what you are wanting ?
Standard deviation of all numbers from the first bar through the
current bar ? or at the current bar are you wanting standard
deviation of the numbers of the most current n bars where n is the
current cycle ?
--- In amibroker@xxxxxxxxxxxxxxx, "treliff" <treliff@xxxx> wrote:
> Fred, thanks for your comments.
>
> Correct about standard deviation, the defined StDevCum(array) is
> really StDev(array, BarIndex() + 1) but this one does not work.
>
> However I'm not sure this is what you are referring to because this
> is not really a "loop".
>
> Could you perhaps be more specific, maybe point me in the direction
> of a loop-less re-write? Highly appreciated.
>
> -treliff
>
> --- In amibroker@xxxxxxxxxxxxxxx, "Fred" <ftonetti@xxxx> wrote:
> > Regardless ... It would appear the only loop that's required is
the
> > one that calc's standard deviation as the built in AFL version
does
> > not take an array for length. The rest of the loops can be
> replaced
> > by arrays and in some cases totally done away with.
> >
> > --- 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=12huu67fu/M=362343.6886682.7839641.1493532/D=groups/S=1705632198:TM/Y=YAHOO/EXP=1124842659/A=2894350/R=0/SIG=10tj5mr8v/*http://www.globalgiving.com">Make a difference. Find and fund world-changing projects at GlobalGiving</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/
|