Problem customizing the TickerList in the built in Relative Performance chart

Starting from the built-in Relative Performance formula:
http://www.amibroker.com/kb/2015/08/29/how-to-add-symbol-labels-to-relative-performance-chart/
I am having trouble trying to customize the Tickerlist components depending on the symbol´s GICs sector. It would be substituting the formula :

_N( TickerList = ParamStr( "Tickers", "...................................." ) );

with something like this:

 if   ( InGICS  ( "25" )  )          _N( TickerList = ParamStr( "Tickers","SPY,XLY" ) );  // Consum.Discretionary
else if   ( InGICS  ( "30" )  )          _N( TickerList = ParamStr( "Tickers","SPY,XLP" ) );   // Consum.Stapes
else if   ( InGICS  ( "10" )  )          _N( TickerList = ParamStr( "Tickers","SPY,XLE" ) );   // Energy

.
.
else _N( TickerList = ParamStr( "Tickers", "............." ) );

The problem that I am encountering is that the chart for the SECTOR stays fixed for all securities, it does not change in accordance with the GICs sector belonging. It must be an error in AFL programming. I have tried other options like changing the grammar by trial and error, like

if ( InGICS ( "25" ) ) { _N( TickerList = ParamStr( "Tickers","SPY,XLY" ) )......

but I cannot make it, the sector chart remains fixed.

Can anyone please help me to find out what´s the AFL error that I am making?
Thanks

Param* functions settings are cached. Also Param* functions do not belong within if else statements.

Param_List1 = ParamStr( "Gics 25", "SPY,XLY" );
Param_List2 = ParamStr( "Gics 30", "SPY,XLP" );
Param_List3 = ParamStr( "Gics 10", "SPY,XLE" );

TickerList = "";
if   ( InGICS( "25" )  )          _N( TickerList = Param_List1 );  // Consum.Discretionary
else if   ( InGICS( "30" )  )          _N( TickerList = Param_List2 );   // Consum.Stapes
else if   ( InGICS( "10" )  )          _N( TickerList = Param_List3 );   // Energy

printf( "\nTickerList: %s", TickerList);

Alternative

Param_List10 = ParamStr( "Gics 10", "SPY,XLE" );
Param_List25 = ParamStr( "Gics 25", "SPY,XLY" );
Param_List30 = ParamStr( "Gics 30", "SPY,XLP" );

TickerList = "";
GicsIDs = "10,25,30";
for ( i = 0; i <= StrCount(GicsIDs, ","); i++ ) {
	id = StrExtract(GicsIDs, i);
	if ( InGICS(id) ) { TickerList = VarGetText("Param_List" + id);  break; }
}

printf( "\nTickerList: %s", TickerList);
3 Likes

Thank you fxshrat. I took the first option, it is good to be in a smart community willing to help the real no-brainers for programming :pray: