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

Re: [amibroker] Re: Correlation Matrix - code help .... GOT IT!



PureBytes Links

Trading Reference Links

I'm really confused now.  I ran the original formula, then a second modified formula, then I computed daily ROC changes and ran a third correlation in Excel to see which one in AB would be closer but I got three completely different results. 
 
the second  variation I tried in AB is this:
(all I did was change the correlation line to Roc(c,1) instead of just C in the original formula.

Filter =

Status("LastBarInTest");

AddTextColumn(FullName(),"Ticker",1.0);

list =

GetCategorySymbols(

categoryWatchlist,

20 );

for(

NumTickers=0; NumTickers < 99 AND StrExtract(

list, NumTickers ) !=

"";

NumTickers++ );

a = ROC(C,1);

 

for(

Col=0;

Col<NumTickers; Col++)

{

Ticker1 =

Name();

Ticker2 =

StrExtract( list, Col);

 

Var1 =

Foreign(Ticker1,"C");

 

Var2 =

Foreign(Ticker2,"C");

 

Test =

Correlation( ROC(Var1,1), ROC(Var2,1),

8 );

Color =

IIf(Test>0,

colorBrightGreen,

IIf(Test<0,

colorRed,

colorWhite));

Color =

IIf(Ticker1==Ticker2,

1, Color);

 

AddColumn( Test,

Ticker2, 1.3,

1, Color);

}



Jason Hart <jhart_1972@xxxxxxxxx> wrote:
Paul,
 
Good point.  I tried substituting in a ROC expression in place of "C" in the 2 foreigns but got the same results. 
 
it went from this:

Var1 =

Foreign(Ticker1,"C");

To this:

Var1 =

Foreign(Ticker1,"ROC(C,1)");

I'm not a great programmer so I have two questions:  1.  is this the correct way of manipulating the foreign argument and  2.  is the original formula already correctly measuring the correlations by using ROC vs. closing price?

Jason

"Paul A." <amibroker@xxxxxxxxxxxxx> wrote:
At 12:58 PM 3/5/2005, you wrote:
I thought I posted this to the forum.  Her'es what I posted:

Yes, I saw it.  I thought that you had tinkered with it further to get it working, so I was asking for the finished code.  Thanks, I'll give it a ride.

I'm curious.  How did you decide to go with correlating the raw prices rather than the price ROCs?



Check AmiBroker web page at:
http://www.amibroker.com/

Check group FAQ at: http://groups.yahoo.com/group/amibroker/files/groupfaq.html



__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com

Check AmiBroker web page at:
http://www.amibroker.com/

Check group FAQ at: http://groups.yahoo.com/group/amibroker/files/groupfaq.html



__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com

Check AmiBroker web page at:
http://www.amibroker.com/

Check group FAQ at: http://groups.yahoo.com/group/amibroker/files/groupfaq.html



Yahoo! Groups Sponsor
ADVERTISEMENT
click here


Yahoo! Groups Links