//The following is a code for relative performance in Amibroker//
_SECTION_BEGIN("Relative Performance");
_N( TickerList = ParamStr("Tickers", "^DJI,SPY,GE") );
NumBars = 20;
fvb = Status("firstvisiblebar");
Plot( 100 * ( C - C[ fvb ] ) / C[ fvb ], Name(), colorBlue );
for( i = 0; ( symbol = StrExtract( TickerList, i ) ) != ""; i++ )
{
fc = Foreign( symbol, "C" );
if( ! IsNull( fc[ 0 ] ) )
{
Plot( 100 * ( fc - fc[ fvb ] )/ fc[ fvb ], symbol, colorLightOrange + ( (2*i) % 15 ), styleLine );
}
}
PlotGrid( 0, colorYellow );
_N( Title = "{{NAME}} - Relative Performance [%]: {{VALUES}}" );
_SECTION_END();
_N( TickerList = ParamStr( "Tickers", "^DJI,MSFT,SPY" ) );
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, y, GetChartBkColor(), color, -fontsize/2 );
}
}
PlotGrid( 0, colorYellow );
_N( Title = "{{NAME}} - Relative Performance [%]: {{VALUES}}" );