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

[amibroker] Re: Correlation fn - no of bars



PureBytes Links

Trading Reference Links

I've never tried the sort of thing you're doing, but can see a couple
of issues.

Firstly, you're trying to set NoBars1 and NoBars2 to the bar index but
you're not using them as arrays, so each assignment of 'i' and 'j'
just overwrites the previous value.

> for(j=0;j<BarCount-10;j++)
> {NoBars1=j;}

In this case, NoBars1 will always end up as the single value
BarCount-11. If you want an array of bar indices, use either Cum(1)
which gives an array starting with one as the first index, or
BarIndex(). However, if you just want the total number of bars, which
it seems to me you do, then just use BarCount directly:

NoBars1 = BarCount;

Also, from my understanding, NoBars2 will always be the same as
NoBars1, as when you access the foreign symbol, it's array is repacked
to align with the currently selected symbol and will have the same
number of bars. Although I'm not sure exactly what you're trying to
achieve, that's probably what you want anyway, as that ensures all
bars are date and time aligned between the two symbols. In that case,
just get the foreign symbol and use BarCount as the correlation period.

Finally, why do you need to access the currently selected symbol using
Foreign in the correlation statement?

Regards,
GP


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