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]);
}