hi, I am working with the correlation matrix, the one shared by fxshrat in this topic: Correlation Matrix
This is the formula by fxhrat:
CorrLB = Param("Lookback", 252, 50, 300, 1); // daily correlation look-back period//
wlnumber = GetOption( "FilterIncludeWatchlist" ); // choose your WL in Analysis window
symlist = GetCategorySymbols( categoryWatchlist, wlnumber );
// display only last bar from the Analysis range
Filter = Status( "lastbarinrange" );
SetSortColumns(1); // I added this to keep the columns and rows in order
Tickers = Name();
// iterate through symbols
logC = log( C / Ref( C, -1 ) );// does not belong within loop
for( i = 0; ( sym = StrExtract( symlist, i ) ) != ""; i++ )
{
Frg = Foreign( sym, "C" ); // store Foreign to variable since it is called multiple times
FrgLog = log( Frg / Ref( Frg, -1 ) );
Corr = Correlation( logC, FrgLog, CorrLB );
// set color dynamically based on correlation values
// and display the output in exploration column
corrcond = Corr>0.6;// used several times
tickercond = Tickers == sym;// used several times
Clr = 32 + SelectedValue( Corr ) * 32;
Clr = IIf( tickercond, colorBlack, Clr );
fntcolor = IIf( tickercond, colorWhite, IIf(corrcond,colorWhite, -1 ));
cellcolor = IIf( tickercond, colorDarkBlue, IIf(corrcond, colorGreen, -1) );
AddColumn( Corr, sym, 1.3, fntcolor, cellcolor, width = 60 );
}
Supposing that I use it in a list with 3 symbols: SPY,XLF, and XLY, this is what I get:
What I want is to get all the information of the matrix but in just one column of Correlations, with another column for the second symbol of the correlation.This would be what I want:
At the moment, I have only been able to do an intermediate step, which is to add an AddColumn to the original formula in order to insert a column with the second symbol of the correlation
AddTextColumn( sym , "Sym");
So now I get this:
I do not know how to arrange all the correlations in one column,
hope anybody can help,
thanks in advance