Arr1=C;
Arr2=Yrs;
Lookback=30;
Covar=correlation (Arr1, Arr2,Lookback)*StDev(Arr1)*StDev(Arr2);
Var=StDev(Arr1)^2;
A few points:
1) Lookback is arbitrary. Longer is better.
2) You're dealing with non-stationary series. Be careful about
interpretation of statistics.
3) Since correlation of a series with itself is 1, Var is simply
StDev-squared.
4) AB's StDev is based on assumed full population, whereas you're
only using a sample. I.e. purists need to adjust for this.
Hopefully, once the account-manager is fully functional, TJ will
think about adding matrix-functions, with which we could easily
create var-covar matrices of portfolio-returns, factor-returtns, etc.
(Yes, I know I can already do this in AFL, but what about an inverted
matrix??)
PS
--- In amibroker@xxxxxxxxxps.com,
"aleskresta" <ales.kresta@...>
wrote:
>
> Greetings,
>
> I am still a little bit confused about arrays in AB, could
someone
> give me an example of one simple thing:
>
> 1)I have an array of Close prices
> 2)I want to create an array(the same length as first) of a number
> 1,2,3, nad so on
> 3)I want to compute covarience between array 1 and array 2, and
> variance of array 2
>
> Because I am confused about arrays I don't know how to do the
second
> thing
>
> Thanks a lot for advice
>