Anyone?
Thanks,
Louis
2008/9/22 Louis P. <[EMAIL PROTECTED]>
>
> Hi,
>
> I have this question about Rsquared.
>
> I used the following code to calculate it:
>
> // variable-period Correlation
> function CorrV( x, y, range )
> {
>
> avX = MA( x, range );
> avY = MA( y, range );
> avXY = MA( x * y, range );
>
> ssqrX = Sum( x * x, range );
> ssqrY = Sum( y * y, range );
>
> VarX = Max( ssqrx/range - avX * avX, 0 );
> VarY = Max( ssqry/range - avY * avY, 0 );
>
> return Nz( ( avXY - avX * avY ) / sqrt( VarX * VarY ) );
> }
>
> // variable-period R squared
> function RSquaredV( array, range )
> {
> return CorrV( BarIndex()+1, array, range ) ^ 2;
> }
>
>
> The problem is shown in the image I just attached. If you look at the last
> graph at the bottom of the image, the first orange line at the bottom is a
> 0.80 correlation. This line has a correlation over 0.85, which is very
> good. However, it is clear to the eye that the close or the HHV was NOT
> taken into account; instead it seems like it is the next bar that is taken
> into account. So I get a result that should not show any correlation at
> all!
>
> How do you think I could correct this?
>
> Thanks,
>
> Louis
>
>