See the Fullname (not only the Name-ticker) in a relative performance chart

hi, I took from the forum this code for charting relative performance for several symbols. As you can see in the chart below, in the Title it shows the symbols Name (the ticker), but I would like to add to the Title the Fullname() but I do not know how to do it. Please help.

Thanks in advance

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
_N( TickerList = ParamStr( "Tickers", "SPY,BND.O,GLD" ) );
fontsize = Param("Label font size", 10, 4, 30, 1 );
fvb = Status( "firstvisiblebar" );

for( i = 0; ( symbol = StrExtract( Name() + "," + TickerList, i ) ) != ""; i++ )
{
    fc = Foreign( symbol, "C" );

    if( ! IsNull( fc[ 0 ] ) )
    {
        relP = 100 * ( fc - fc[ fvb ] ) / fc[ fvb ];
        Plot( relP , symbol, color = colorLightOrange + ( ( 2 * i ) % 15 ), styleLine );

        x = LastValue( BarIndex() ) + 1;
        y = LastValue( relP );

        PlotTextSetFont( symbol, "Arial", fontsize, x+4, y, GetChartBkColor(), color, -fontsize/2 );
    }
}

PlotGrid( 0, colorYellow );
_N( Title = "{{NAME}} - Relative Performance [%]: {{VALUES}}" ); type or paste code here

imagen

See full-name-in-the-price-chart.

I already use this formula full-name-in-the-price-chart to see the full name in my own charts. The problem is that it does not work in this formula, for it is different, it does not start with:

_N(Title = StrFormat(.........

  1. It is a loop, not a regualr code:

for( i = 0; ( symbol = StrExtract( Name() + "," + TickerList, i ) ) != ""; i++ )

  1. In the Title, as I said, there is no: StrFormat(.....

_N( Title = "{{NAME}} - Relative Performance [%]: {{VALUES}}" );

I have tried to insert the Fullname() in different places of the code, but I either loose information or I get an error.

The difficult thing is to get the Fullname() for ALL the symbols involved, the dificulty has to do probably with the loop code,

Thanks anyway

Mariano

You are using (mod.) "Relative Performance" AFL of Basic Charts folder of AB installation.

Do get fullname instead of symbol everywhere in Title do like so:

// derived from "Relative Performance.afl" of Basic Charts folder
// Modified to output FullName instead of ticker name in Title
_N( TickerList = ParamStr( "Tickers", "^GSPC,MSFT,GE" ) );

fvb = Status( "firstvisiblebar" );

Plot( 100 * ( C - C[ fvb ] ) / C[ fvb ], FullName(), colorBlue );

for ( i = 0; ( symbol = StrExtract( TickerList, i ) ) != ""; i++ )
{
    SetForeign( symbol, 1, 0 );
    
		fc = C;

		if ( NOT IsNull( fc[ 0 ] ) )
		{
			Plot( 100 * ( fc - fc[ fvb ] ) / fc[ fvb ], FullName(), colorLightOrange+((2*i) % 15), styleLine );
		}
}

PlotGrid( 0, colorYellow );
_N( Title = "{{FULLNAME}} - Relative Performance [%]: {{VALUES}}" );

1


Or like this (to output name and fullname)

// derived from "Relative Performance.afl" of Basic Charts folder
// Modified to output FullName + ticker name in Title
_N( TickerList = ParamStr( "Tickers", "^GSPC,MSFT,GE" ) );

fvb = Status( "firstvisiblebar" );

Plot( 100 * ( C - C[ fvb ] ) / C[ fvb ], Name() + "/" + FullName(), colorBlue );

for ( i = 0; ( symbol = StrExtract( TickerList, i ) ) != ""; i++ )
{
    SetForeign( symbol, 1, 0 );
    
		fc = C;

		if ( NOT IsNull( fc[ 0 ] ) )
		{
			Plot( 100 * ( fc - fc[ fvb ] ) / fc[ fvb ], Name() + "/" + FullName(), colorLightOrange+((2*i) % 15), styleLine );
		}
}

PlotGrid( 0, colorYellow );
_N( Title = "{{NAME}}/{{FULLNAME}} - Relative Performance [%]: {{VALUES}}" );

1

etc....

4 Likes

Thanks fxshrat :ok_hand: