Try this:

function GetCurrentWatchlist()
{
     AB = CreateObject( "Broker.Application" );
     AA = AB.Analysis;
     return AA.Filter( 0, "watchlist" );
}

function RetrieveSymbolList( )
{
     return CategoryGetSymbols( categoryWatchlist, GetCurrentWatchlist()
);
}

_TRACE( "Symbols: " + RetrieveSymbolList() );


Mike


--- In [email protected], "nunopires2001" <nunopires2...@...>
wrote:
>
> --- In [email protected], "nunopires2001" nunopires2001@
wrote:
> >
> > Hello,
> >
> > There is any way to retrieve the currently selected watchlist?
> >
> > Many thanks,
> > Nuno
> >
> I will try to explain in more detail my problem.
>
> I have a graphic where i plot the correlation between 2 stocks.
> The code used:
> _________________________________________________________________
> include
"C:\bolsa\AmiBroker5\Formulas\Custom\PairTrading\includes\utils.afl"
>
>
> period=60;
> list=RetrieveSymbolList();
> sym0 = StrExtract( list, 0 );
> sym1 = StrExtract( list, 1 );
>
> _correlation = Correlation( Foreign( sym0, "C") , Foreign( sym1, "C"),
period);
>
> Plot( _correlation , "correlation"+period + " " + sym0 + "-" + sym1 ,
colorLightBlue,4);
> ___________________________________________________________________
> where utils.afl is:
>
> function RetrieveSymbolList( ) {
>
> for( i = 0; CategoryGetName( categoryWatchlist, i )!= ""; i++ )
> {
> if( InWatchList( i ) ) _list = CategoryGetSymbols( categoryWatchlist,
i );
> }
>
> return _list;
>
> }
>
> _____________________________________________________________________
>
> I populate each watchlist with 2 symbols, I select one of the 2 stocks
on the watchlist, and the correlation between them is plotted.
> Everything works well, except when i have the same symbol on multiple
watchlists.
> On that case, the correlation plotted is from the last watchlist where
the selected symbol is found, not the actual one.
>
> Anyone can suggest me a way to correct the code?
>


Reply via email to