Re: [amibroker] Correlation for Period as Array

 



First of all, I would not call the function Correlation. Amibroker has a function called Correlation. So call it something like Correl. If you want an adaptive moving average, you could use the AMA function in stead of MA. Do not ask me what you're getting as a result for the correlation from a mathematical point …

 

function CorrelB( x, y, period )

{

    mp       = 2 / ( Period + 1 );

    nom     = AMA( x * y, mp ) - AMA( x, mp ) * AMA( y, mp );

    denom                 = sqrt( AMA( x^2, mp ) - AMA( x, mp ) ^ 2 ) *

                                                               sqrt( AMA( y^2, mp ) - AMA( y, mp ) ^ 2 );

    denom                 = IIf(denom > 0, denom, 0.01 );

    return nom / denom;

}

 

Regards, Ton.

 

----- Original Message -----
Sent: Sunday, May 22, 2016 4:20 PM
Subject: Re: [amibroker] Correlation for Period as Array

 

Your AFL skills are far better than mine, but I can say you probably mean to have nom as num, since you're referring to the numerator.
Small English issue, but you may as well have it right.
Good luck getting your answer from someone who knows AFL a lot better than I do.

On Sun, May 22, 2016 at 10:35 PM, meanomalist@yahoo.com [amibroker] <amibroker@yahoogroups.com> wrote:
 

Dear AFL Experts,

The Calculation of Correlation() has below logic:

function Correlation( x, y, period )
{
nom= MA( x * y, period ) - MA( x, period ) * MA( y, period );
denom = sqrt( MA( x ^ 2, period ) - MA( x, period ) ^ 2 ) *
sqrt( MA( y ^ 2, period ) - MA( y, period ) ^ 2 );
return nom/denom;
}

Note: X and Y are array1 and array2. period is not an array but a static number.

The issue I am facing is, I need to pass the parameter "Period" Dynamically and not  Static Period. I have an array called "period".

But above function only accepts a period as a static value and not array.

Any one can help me with hacking this? It's lot more challanging for my AFL skills yet.




--
Karl Bergerson (カール バーガーソン)

〒002-0857
 札幌市北区屯田7条11丁目10-10
電話 050-5809-7325 (Skype)

__._,_.___

Posted by: "Ton Sieverding" <ton.sieverding@scarlet.be>
Reply via web post Reply to sender Reply to group Start a New Topic Messages in this topic (3)

Upgrade your account with the latest Yahoo Mail app
Get organized with the fast and easy-to-use Yahoo Mail app. Upgrade today!

**** IMPORTANT PLEASE READ ****
This group is for the discussion between users only.
This is *NOT* technical support channel.

TO GET TECHNICAL SUPPORT send an e-mail directly to
SUPPORT {at} amibroker.com

TO SUBMIT SUGGESTIONS please use FEEDBACK CENTER at
http://www.amibroker.com/feedback/
(submissions sent via other channels won't be considered)

For NEW RELEASE ANNOUNCEMENTS and other news always check DEVLOG:
http://www.amibroker.com/devlog/


.

__,_._,___


EmoticonEmoticon