Stock Market Quilt

i am interested in creating a Stock Market Quilt/Performance Chart for a basket of investments like:

i have done some searches to see if there are any readily available examples (maybe i am searching for the wrong terms). before going and doing it myself is anyone familiar with examples of this type of 'analysis'/report?

thanks in advance!!

peter

You may go to AmiBroker members library for heatmap example
http://www.amibroker.com/members/library/detail.php?id=1213

8

7 Likes

thank you for the head start!! just sharing my work here. please let me know if you can improve upon this or if something seems incorrect:

symlist = "IWD,IWF,IWN,IWO,ACWX,AGG,REET,GSG,SHV,IWV"; 
colorlist[0] = colorIndigo;
colorlist[1] = colorDarkBlue;
colorlist[2] = colorLightBlue;
colorlist[3] = colorBrown;
colorlist[4] = colorRed;
colorlist[5] = colorOrange;
colorlist[6] = colorGreen;
colorlist[7] = colorSeaGreen;
colorlist[8] = colorAqua;
colorlist[9] = colorYellow;
isLastOfMonth = TimeframeExpand(1, inMonthly, expandPoint);
EndOfYear = TimeframeExpand(1, inYearly, expandPoint);

// delete static variables 
StaticVarRemove( "yoyReturn*" ); 

// fill input static arrays 
for ( i = 0; ( sym = StrExtract( symlist, i ) ) != ""; i++ ) 
{ 
	SetForeign( sym );
	pymec = TimeFrameGetPrice( "C", inmonthly, -12 );
	yoyr = ( c - pymec ) / pymec * 100;
	RestorePriceArrays(); 
    StaticVarSet( "yoyReturn" + sym, yoyr ); 
}

// perform ranking 
StaticVarGenerateRanks( "rank", "yoyReturn", 0, 1223 ); // normal rank mode 

NumTickers = 10;
NumColumn = 12;
Font = "Calibri";

ScreenHeight = Status ( "pxheight" )  ; 
ScreenWidth = Status ( "pxwidth" ) ; 
ChartHeight = ScreenHeight - 2   ; 
ChartWidth = ScreenWidth - 2 ; 

//SetChartBkColor(Nz(xStaticVarGet("BackGroundColor")));
//====================================================================
// THE GRAPHIC PRESENTATION:
//====================================================================
 //x2			= Status("pxchartright");
 //y2 		= Status("pxchartbottom");
 PenColor 	= colorBlack;
 TxtColor	= colorBlack;

 //Width 	= x2 / sqrt(NumTickers);
 //Hight	= y2 / sqrt(NumTickers);
 Width 	= ChartWidth / NumColumn;
 Hight	= ChartHeight / (NumTickers + 1);
 StartX	= 1;
 StartY	= 1;

 PointSize	= Width/7;
 Weight	= 100;
 GfxSelectPen(PenColor, 2); 
 //GfxSelectSolidBrush( colorGrey40 ); // Cell Background Fill
 //GfxSetTextColor(colorWhite); 
 GfxSelectFont(Font, PointSize, Weight); 
 //GfxSetBkColor(colorGrey40); //Font Background Fill
 GfxSetBkMode(2);
 
 //yr = 2018;
 yr = LastValue( Year() );
 for( col = 0; col < NumColumn; col++ ) 
 {
	//////////////////////////////////////////////////////////////////
	//HEADER ROW
	//////////////////////////////////////////////////////////////////
	row = 0;
	GfxSelectSolidBrush( colorGrey40 ); // Cell Background Fill
	GfxSetBkColor(colorGrey40); //Font Background Fill
	GfxSetTextColor(colorWhite); 
	//GfxRoundRect( StartX + (col * Width), StartY + (row * Hight), Width * (col+1), Hight * (row+1) / 2, 15, 15 );
	GfxRoundRect( StartX + (col * Width), StartY + (row * Hight), Width * (col+1), Hight * (row+1), 15, 15 );
	info = yr - 11 + col;
	PlotInformation = writeIf(info >= yr, "YTD", StrFormat("%g", info));
	//GfxDrawText(PlotInformation, StartX + (col * Width), 5 + StartY + (row * Hight), Width * (col+1), Hight * (row+1) / 2, 1);
	GfxDrawText(PlotInformation, StartX + (col * Width), 10 + StartY + (1 * Hight) / 5, Width * (col+1), Hight * (row+1), 1);	
	
	//////////////////////////////////////////////////////////////////
	//ADD ROWS TO COLUMN
	//////////////////////////////////////////////////////////////////
	blFind = EndOfYear && ( Year() == info );
	for ( i = 0; ( sym = StrExtract( symlist, i ) ) != ""; i++ ) 
	{
		GfxSelectSolidBrush( colorlist[i] ); // Cell Background Fill
		GfxSetBkColor( colorlist[i] ); //Font Background Fill
		GfxSetTextColor( IIf( i > 7, colorBlack, colorWhite ) ); 
		ret = LastValue( ValueWhen( blFind, StaticVarGet( "yoyReturn" + sym ) ) );
		row = LastValue( ValueWhen( blFind, StaticVarGet( "RankyoyReturn" + sym ) ) );
		GfxRoundRect( StartX + (col * Width), StartY + (row * Hight), Width * (col+1), Hight * (row+1), 15, 15 );
		PlotInformation = sym + "\r" + NumToStr( ret, 1.2 ) + "%";
		GfxDrawText(PlotInformation, StartX + (col * Width), 5 + StartY + (row * Hight), Width * (col+1), Hight * (row+1), 1);
	}
 }

3 Likes