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

[amibroker] Re: Correlation fn - no of bars



PureBytes Links

Trading Reference Links

Hugh, it sounds like you are trying to use this in an exploration 
where each security might have a different start date.  If you are 
trying to calculate the correlation since inception for a group of 
securities then this will work:

// Correlation to S&P 500 since inception
Filter =1;
IndexSym = ParamStr("S&P 500","SP-DA"); // set ticker for your quote 
provider
Index = Foreign(IndexSym,"C"); 
Per = BarCount -2; // maximum period that can be calculated
Cor = Correlation(ROC(C,1),ROC(Index,1),Per);
AddColumn(Cor, "S&P"+Per, 1.2);

In the AA window, set n=1 and run explore against your watchlist and 
it will calculate "lifetime" correlation to the S&P.

This works as long as the history of the security in your watchlist 
is less than or equal to the "index" security.


--- In amibroker@xxxxxxxxxxxxxxx, "huandy631" <hugh.andersen@xxx> 
wrote:
>
> Thanks for the reply GP. Still no luck.
> 
> I've tried the following, but although Period=the few number of 
bars 
> I don't get a correlation result.
> 
> ...
> for( i = 0; ( sym2 = StrExtract( List2, i ) ) != ""; i++ ) 
> {
> 
> NoBars1=NoBars2=0;
> for(j=0;j<BarCount-10;j++)
> {NoBars1=j;}
> 
> SetForeign(sym2);
> for(m=0;m<BarCount-10;m++)
> {NoBars2=m;}
> RestorePriceArrays();
> Period=Min(NoBars1,NoBars2);
> 
> AddColumn(Correlation(Foreign(Name(),"close",True),Foreign
> (sym2,"Close",True),Period),sym2);
> }
> 
> 
> any ideas?
> 
> regards
> 
> Hugh
> 
> --- In amibroker@xxxxxxxxxxxxxxx, "gp_sydney" <gp.investment@> 
> wrote:
> >
> > The constant "BarCount". All arrays in the same context have the 
> same
> > number of bars.
> > 
> > Regards,
> > GP
> > 
> > 
> > --- In amibroker@xxxxxxxxxxxxxxx, "huandy631" <hugh.andersen@> 
> wrote:
> > >
> > > I am trying to find out the correlation between two arrays for 
> all 
> > > bars in the array, not just a subset. There has to be a simple 
> way of 
> > > finding out the number of bars in an array? I just don't see it.
> > > 
> > > eg 
> > > period=min(no bars array 1, no bars array2)
> > > correl=correlation(array1,array2,period)
> > > 
> > > thanks
> > > Hugh
> > >
> >
>




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 NEW RELEASE ANNOUNCEMENTS and other news always check DEVLOG:
http://www.amibroker.com/devlog/

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/

<*> Your email settings:
    Individual Email | Traditional

<*> To change settings online go to:
    http://groups.yahoo.com/group/amibroker/join
    (Yahoo! ID required)

<*> To change settings via email:
    mailto:amibroker-digest@xxxxxxxxxxxxxxx 
    mailto:amibroker-fullfeatured@xxxxxxxxxxxxxxx

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