[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [amibroker] How to combine Arrays? I am trying to calc stdev of H,L,C over 20 days
PureBytes Links
Trading Reference Links
|
Sorry, I don't believe
that Howard's first solution below is correct. Consider a very simple
example. Stock has a high of $3, a low of $1, and a close of $2, every one of the 20 days. The arrays of H, L, and C,
have means of $3, $1, and $2 respectively. And all three arrays have
STDevs (about their own means) of $0. However, all highs, lows, and
closes taken as a single set have a mean of $2 and a STDev of $0.8165.
Howard's second solution is correct.
However, a simpler AmiBroker
form of it, without
looping, is:
N=20;
STDev = ((MA(H*H,N)+MA(L*L,N)+MA(O*O,N))/3
- ((MA(H,N)+MA(L,N)+MA(O,N))/3)^2)^0.5;
An interesting (though probably not approved by those who approve
proper mathematical thingys) experiment, might be to replace MA() with
EMA() above, just to see what it looks like.
I happen to be partial to EMA()s.
-- Keith
Howard B wrote:
Hi Ramon --
Try computing the standard deviation of each series separately,
squaring each (those squared values are the variances), adding the
variances, and taking the square root of the sum of the variances. Is
that the number that agrees with what you are looking for?
If not, look up the formula for computing the standard deviation of a
series of number. The program a for loop 20 days long. Within the
loop you will be processing three days points (HLC) every day instead
of just one (C).
Thanks,
Howard
On Tue, Sep 8, 2009 at 7:01 AM, ramoncummins
<ramoncummins@hotmail.com>
wrote:
Hi There
I am trying to calculate the standard deviation of the high,low and
close prices for the last twenty days. In effect I wait the stdev of 60
pieces of data (20days * 3 data points). For reference, I am trying to
replicate highlighting 60 cells in excel and calculating stdev on them.
I've thought about combing the h,l,c arrays but don't know how to do
this.
Please note that neither of the following are correct:
stdev(H+L+C, 20);
(stdev(h,20)+stdev(l,20)+stdev(c,20) / 3); //this
produces similar result but not *exactly* the correct result
Any help much appreciated.
Cheers
Ramon
__._,_.___
**** 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/
__,_._,___
|
|
|
|
|