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

RE: [amibroker] Re: StDev question



PureBytes Links

Trading Reference Links



On further examination I can confirm that StDev doesn’t like null in bar zero. I changed the code to the following and now it calculates the std correctly. However, I  still don’t understand why Tomasz designed it this way. Why should StDev care that bars outside its scope of calculation is null or not?

 

Chg = ROC(   Close,1);
STD =
StDev(Chg, 5);
NzChg =
Nz(Chg);
NzSTD =
StDev(NzChg, 5);

for( i = 0 ; i < 10; i++ )
{
_TRACE("i: " + i + " close: " + C[i] + " Chg: " + Chg[i] + " STD: " + STD[i] + "  NzChg:  " + NzChg[i] + "  NzSTD:  " + NzSTD[i]  );
}

 

 

test1.jpg

 

From: amibroker@xxxxxxxxxxxxxxx [mailto:amibroker@xxxxxxxxxxxxxxx] On Behalf Of Mike
Sent: Tuesday, August 18, 2009 3:13 PM
To: amibroker@xxxxxxxxxxxxxxx
Subject: [amibroker] Re: StDev question

 

 

Right. Sorry, too quick on the draw on my part.

Mike

--- In amibroker@xxxxxxxxxxxxxxx, "ta" <tagroups@xxx> wrote:
>
> Sorry I meant to say Bar 0 of Chg array is Null. Bars 1 thru 5 have values,
> so on bar 5 StDev should NOT return null.
>
>
>
>
>
> From: amibroker@xxxxxxxxxxxxxxx [mailto:amibroker@xxxxxxxxxxxxxxx] On Behalf
> Of ta
> Sent: Tuesday, August 18, 2009 2:45 PM
> To: amibroker@xxxxxxxxxxxxxxx
> Subject: RE: [amibroker] Re: StDev question
>
>
>
>
>
> Mike
>
>
>
> Bar 0 of Chg array is zero. Bars 1 thru 5 have values, so on bar 5 StDev
> should NOT return null.
>
>
>
> test.jpg
>
>
>
> From: amibroker@xxxxxxxxxxxxxxx [mailto:amibroker@xxxxxxxxxxxxxxx] On Behalf
> Of Mike
> Sent: Tuesday, August 18, 2009 2:38 PM
> To: amibroker@xxxxxxxxxxxxxxx
> Subject: [amibroker] Re: StDev question
>
>
>
>
>
> I suspect that the problem is that your first element in the Chg array is
> {empty}. AmiBroker is probably waiting for 5 non empty values before giving
> an answer.
>
> Mike
>
> --- In amibroker@xxxxxxxxxxxxxxx <mailto:amibroker%40yahoogroups.com> , "ta"
> <tagroups@> wrote:
> >
> > The following is a screen shot of an excel spread sheet that contains data
> > from the trace statement below. As you can see I am trying to calculate 5
> > bars std of array "Chg". What I don't understand is that why StDev returns
> > null on bar index 5. It has 5 data points to calculate the STD. Using
> excel
> > function STDEVP I was able to calculate the std for bar index 5. I have
> > noticed similar behavior with the Correlation and LinRegSlope functions.
> > What I am missing? I have gotten around this issue by writing my own STD
> > function. TIA
> >
> >
> >
> >
> > Bar Index
> >
> > close
> >
> > Chg
> >
> > STD
> >
> > STDEVP
> >
> >
> > 0
> >
> > 4.2813
> >
> > {EMPTY}
> >
> > {EMPTY}
> >
> >
> >
> > 1
> >
> > 4.25
> >
> > -0.731088
> >
> > {EMPTY}
> >
> >
> >
> > 2
> >
> > 4.2813
> >
> > 0.736472
> >
> > {EMPTY}
> >
> >
> >
> > 3
> >
> > 4.4063
> >
> > 2.91967
> >
> > {EMPTY}
> >
> >
> >
> > 4
> >
> > 4.4063
> >
> > 0
> >
> > {EMPTY}
> >
> >
> >
> > 5
> >
> > 4.375
> >
> > -0.710348
> >
> > {EMPTY}
> >
> > 1.35092
> >
> >
> > 6
> >
> > 4.2813
> >
> > -2.14171
> >
> > 1.67506
> >
> > 1.67506
> >
> >
> > 7
> >
> > 4.25
> >
> > -0.731088
> >
> > 1.67705
> >
> > 1.67705
> >
> >
> > 8
> >
> > 4.2813
> >
> > 0.736472
> >
> > 0.953698
> >
> > 0.95370
> >
> >
> > 9
> >
> > 4.3125
> >
> > 0.728749
> >
> > 1.07725
> >
> > 1.07725
> >
> >
> >
> > Chg = ROC( Close,1);
> > STD = StDev(Chg, 5);
> > for( i = 0 ; i < 10; i++ )
> > {
> > _TRACE("i: " + i + " close: " + C[i] + " Chg: " + Chg[i] + " STD: " +
> > STD[i]);
> > }
> >
>



__._,_.___


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

__,_._,___

JPEG image

JPEG image