Traders Laboratory - View Single Post - Excel Help Needed
View Single Post
  #1 (permalink)  
Old 04-16-2008, 08:59 PM
thrunner thrunner is offline
thrunner has no status.

 
Join Date: Feb 2007
Posts: 215
Thanks: 67
Thanked 62 Times in 36 Posts
Re: Excel Help Needed

Sorry, don't really program Excel but here is a link for doing Pearson correlation in Excel: http://www.mnstate.edu/wasson/ed602calccorr.htm

However, correlation of multiple data series is fairly easy in Tradestation EL. One can import more data points and additional data series as well (such as the other sectors).


re: code for TS Correlation:
Insert 15 min chart SPY as data 1, XLF, XLE, XLY, XLP as data 2,3,4,5 respectively. You will need real time subscription if you are using TS for mixing these data. MC doesn't complain as much about these data. Then apply the following indicator (name it Correlation4 for example):
Quote:
inputs:
IndepData( Close of data1 ),
DepData1( Close of data2 ),
DepData2( Close of data3 ),
DepData3( Close of data4 ),
DepData4( Close of data5 ),

Length( 26 ),
Length2(3),
PosCorrAlert( .7 ),
NegCorrAlert( -.7 ) ;

variables:
CorrelVal( 0 ),
CV1(0), CV2(0), CV3(0), CV4(0)
;


//CorrelVal = ( Correlation( IndepData, DepData, Length ) +
CV1= DepData1;
CV2= DepData2;
CV3= DepData3;
CV4= DepData4;


CorrelVal = ( Correlation( CV2, CV1, Length ) +
Correlation( CV3, CV2, Length ) +
Correlation( CV4, CV1, Length ) +
Correlation( CV4, CV2, Length ) +
Correlation( CV4, CV3, Length ) +
Correlation( CV1, CV3, Length ) ) / 6
;

//Plot1( jtHMA(CorrelVal, 6) , "Correl" ) ;
Plot1 (CorrelVal, "Correl");
//Plot2( PosCorrAlert, "PosCorrAlert" ) ;
//Plot3( NegCorrAlert, "NegCorrAlert" ) ;

{ Alert criteria }
if CorrelVal crosses over PosCorrAlert then
Alert( "Positive correlation alert" )
else if CorrelVal crosses under NegCorrAlert then
Alert( "Negative correlation alert" ) ;
Attached Images
File Type: gif Correlation4 SPY XLF 2008-04-16_194642.gif (20.9 KB, 182 views)


Last edited by thrunner; 04-16-2008 at 10:08 PM.
Reply With Quote