amibroker

HomeKnowledge Base

How to add symbol labels to Relative Performance chart

The built-in Relative Performance chart displays symbol names colored respectively in the chart Title. However – it may be practical to display the symbol label next to the plotted line for easier identification. This can easily be done with PlotText or PlotTextSetFont function.

A sample code showing such modification is presented below. Font size of the labels can be changed through Parameters dialog.

_NTickerList ParamStr"Tickers""^DJI,MSFT,GE" ) );
fontsize Param("Label font size"10430);
fvb Status"firstvisiblebar" );

for( 
0; ( symbol StrExtractName() + "," TickerList) ) != ""i++ )
{
    
fc Foreignsymbol"C" );

    if( ! 
IsNullfc] ) )
    {
        
relP 100 * ( fc fcfvb ] ) / fcfvb ];
        
PlotrelP symbolcolor colorLightOrange + ( ( ) % 15 ), styleLine );

        
LastValueBarIndex() ) + 1;
        
LastValuerelP );

        
PlotTextSetFontsymbol"Arial"fontsizexyGetChartBkColor(), color, -fontsize/);
    }
}

PlotGrid0colorYellow );
_NTitle "{{NAME}} - Relative Performance [%]: {{VALUES}}" )

Relative Performance with labels

Comments are closed.