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

[amibroker] Re: A question concerning Rsquared



PureBytes Links

Trading Reference Links

Anyone?

Thanks,

Louis

2008/9/22 Louis P. <rockprog80@xxxxxxxxx>

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


__._,_.___

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




Your email settings: Individual Email|Traditional
Change settings via the Web (Yahoo! ID required)
Change settings via email: Switch delivery to Daily Digest | Switch to Fully Featured
Visit Your Group | Yahoo! Groups Terms of Use | Unsubscribe

__,_._,___