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

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



PureBytes Links

Trading Reference Links

--- In amibroker@xxxxxxxxxxxxxxx, "vlanschot" <ecbu@xxxx> wrote:
> Fred, just one comment. Unless you assume that you capture the 
whole 
> population (which I would argue you're not; you're dealing with 
> samples), the formula below is biased and needs a slight adjustment:
> 
> CDiff2n[i] = CDiff2[i] / (n[i]-1); 
> 
> This way you adjust for using the mean in your estimates.
> 
> Sorry for being a purist.
> 
> PRS 
> --- In amibroker@xxxxxxxxxxxxxxx, "Fred" <ftonetti@xxxx> wrote:
> > That's probably correct given what you are after ... Just be 
> careful 
> > what you put inside the loop .vs. outside and that you only do 
full 
> > array calc's where necessary ...
> > 
> > I changed your oscillator function ( 10 - 50 ) and I haven't 
> checked 
> > the rest  thoroughly, but this should get you close to where you 
> want 
> > to go.  Notice I calced n outside the loop as there's no reason 
for 
> > it to be inside and that some of the calcs inside the loop are 
not 
> > full array calcs.  I did try playing with some things like Sum(X, 
n
> > [i]) in place of Cum(X) but there don't appear to be any real 
time 
> > savings.  Exacerbating the problem is that indicator code is 
> > typically run several times.  Try running what's below as a plot 
> and 
> > then as an explore and you'll see a noticable difference in how 
> much 
> > clock time is used.  There are ways to keep this from happening 
> with 
> > indicators but I forget what they are off the top of my head. 
> > 
> > X = (sin(Cum(0.01)) + 2) * 20 - 10;;
> > 
> > n = BarIndex() + 1;
> > 
> > for (i = 0; i < BarCount; i++) 
> > { 
> >     CumX = Cum(X); 
> >     Mean[i] = CumX[i] / n[i]; 
> >     Diff = X - Mean[i]; 
> >     Diff2 = Diff ^ 2; 
> >     CDiff2 = Cum(Diff2); 
> >     CDiff2n[i] = CDiff2[i] / n[i]; 
> >     StDevX[i] = sqrt(CDiff2n[i]); 
> > }
> > 
> > Plot(StDevX, "StDevX", colorWhite);
> > 
> > Filter = 1;
> > AddColumn(StDevX, "StDevX", 1.4);
> > 
> > 
> > --- In amibroker@xxxxxxxxxxxxxxx, "treliff" <treliff@xxxx> wrote:
> > > > That doesn't seem to be relevant as at any given bar a 
> particular 
> > > > Length would be in play for the MA calculated at that bar.  
> There 
> > > > wouldn't appear to be a need to fill an array with the same 
> > > > number ...
> > > 
> > > Perhaps not in the MA example, but in my particular code there 
is 
> > > substantial difference between dispersion and min/max values 
(and 
> > > consequently stdev's) related to Cycle 10 and Cycle 50, so yes, 
if
> > > I'm 
> > > currently in Cycle 10-mode, I want stdev calculated strictly 
over 
> > > Cycle 10's.
> > > 
> > > > If you'd like to continue this please email me offline ...
> > > 
> > > You helped me remove the 1st loop, I'm pretty certain I'll
> > > have to 
> > > live with the 2nd one... Thanks for all your help.
> > > 
> > > -treliff




------------------------ Yahoo! Groups Sponsor --------------------~--> 
Put more honey in your pocket. (money matters made easy).
http://us.click.yahoo.com/r7D80C/dlQLAA/cosFAA/GHeqlB/TM
--------------------------------------------------------------------~-> 

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/