PureBytes Links
Trading Reference Links
|
Louis --
May I suggest the following:
1. Reduce to the minimum the code required to demonstrate your problem.
2. Post the code so derived in it Entirety, so that someone who wants
to help can easily reproduce your problem.
In your email below, you may have included that snippet of code which
you feel is at fault. However, you do not know this for sure,
otherwise, you would have probably already solved the problem.
Therefore, post the Entire code required to show your resulting
line and the values you are observing, including plot() functions, and
all pertinent parameter assignments. And remove anything that is
superfluous to your problem, such as plotting of moving averages.
-- Keith
Louis P. wrote:
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
__,_._,___
|
|