Tickers from Watchlist are not updating after changing the watchlist name

When I change the Watchlist Name , The Ticker Symbols from the Selected Watchlist are not updating. Is there any other Method to achieve this?

Page

_SECTION_BEGIN("Relative Performance 4");


WatchlistName = ParamList("WatchList", "Nifty-Auto,Nifty-Bank");
wlnumber = CategoryFind(WatchlistName, categoryWatchlist ); 
Watchlist = CategoryGetSymbols( categoryWatchlist, wlnumber );

SymbolList = StrReplace(Watchlist, ",", ",");

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

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 );
_SECTION_END();

Note:- I referred this thread before posting this question

@amisur, remove the unneeeded ParamStr call.

_SECTION_BEGIN("Relative Performance 4");
WatchlistName = ParamList("WatchList", "List 0,List 1");
_TRACE(WatchlistName);
wlnumber = CategoryFind(WatchlistName, categoryWatchlist ); 
// watchlist = CategoryGetSymbols( categoryWatchlist, wlnumber );
tickerlist = CategoryGetSymbols( categoryWatchlist, wlnumber );
_TRACE("WL number " + wlnumber);
// SymbolList = StrReplace(Watchlist, ",", ",");
// _TRACE("Symbol list" + symbollist);
// _N( TickerList = ParamStr( "Tickers", Symbollist ) );
_TRACE("Ticker list" + tickerlist);
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 );
_SECTION_END();

I did not check the rest of code.

1 Like

This is improper code line.

Parameters are cached. So you should not insert variable code. Symbollist is variable that changes.
So remove ParamStr.

_N( TickerList = Symbollist );

or simply use Watchlist variable instead of TickerList.


Lol all of the sudden 2nd post has changed.


BTW, @amisur

Tomasz has told you here something about code copy:

Main code you copied is from here
https://www.amibroker.com/kb/2015/08/29/how-to-add-symbol-labels-to-relative-performance-chart/

2 Likes

@amisur, please, note that for a quick test, in the above snippet I changed your watchlists names (replace them as per your original code).

1 Like

@beppe
Thank you for the help. Everything is perfect now.

@fxshrat

Thank you for the help. I am sorry, I will make it sure that I strictly adhere with the forum rules from my next post. I picked the code randomly from a folder and I was not aware that the code was a part of Knowledge Base Article. Nothing was intentional nor meant any kind of disrespect to the authors.

This topic was automatically closed 100 days after the last reply. New replies are no longer allowed.