November 13, 2014
How to add exploration results to a watchlist
In order to add analysis results to a selected watchlist manually, we can use context menu from the results list:
There is, however, a way to automate this process and add the symbols to a watchlist directly from the code. To do so, we need to:
– check if our Filter variable was true at least once in the tested Analysis range
– based on the above condition, use CategoryAddSymbol() function to add tickers to a watchlist.
Additionally, we can erase the watchlist at the beginning of the test if we want to store just the new results.
The code below shows how to implement this procedure in AFL.
listnum = 10; // we use watchlist 10 for storing results
// erase the watchlist when we process very first symbol
if ( Status( "stocknum" ) == 0 )
{
// retrieve watchlist members
oldlist = CategoryGetSymbols( categoryWatchlist, listnum );
// iterate through the list and remove tickers
for ( i = 0; ( sym = StrExtract( oldlist, i ) ) != ""; i++ )
{
CategoryRemoveSymbol( sym, categoryWatchlist, listnum );
}
}
// sample exploration code
Filter = ROC( Close, 1 ) > 3 AND Volume > 1000000;
AddColumn( Close, "Close" );
AddColumn( ROC( Close, 1 ), "ROC" );
AddColumn( Volume, "Volume" );
// check how many times Filter variable was true in the tested range
// if non-zero value detected, add current symbol to a watchlist
if ( LastValue( Cum( Filter AND Status( "barinrange" ) ) ) )
CategoryAddSymbol( "", categoryWatchlist, listnum )
Filed by Tomasz Janeczko at 2:32 pm under Exploration
Comments Off on How to add exploration results to a watchlist