{"id":705,"date":"2014-11-13T14:32:37","date_gmt":"2014-11-13T19:32:37","guid":{"rendered":"http:\/\/www.amibroker.com\/kb\/?p=705"},"modified":"2014-12-04T08:24:44","modified_gmt":"2014-12-04T13:24:44","slug":"how-to-add-exploration-results-to-a-watchlist","status":"publish","type":"post","link":"https:\/\/www.amibroker.com\/wordpress\/kb\/2014\/11\/13\/how-to-add-exploration-results-to-a-watchlist\/","title":{"rendered":"How to add exploration results to a watchlist"},"content":{"rendered":"

In order to add analysis results to a selected watchlist manually, we can use context menu from the results list:<\/p>

\"Add<\/p>

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<\/strong> variable was true at least once in the tested Analysis range
– based on the above condition, use CategoryAddSymbol<\/strong>() function to add tickers to a watchlist.<\/p>

Additionally, we can erase the watchlist at the beginning of the test if we want to store just the new results.<\/p>

The code below shows how to implement this procedure in AFL.<\/p>listnum <\/span>= <\/span>10<\/span>; <\/span>\/\/ we use watchlist 10 for storing results

\/\/ erase the watchlist when we process very first symbol
<\/span>if ( <\/span>Status<\/span>( <\/span>"stocknum" <\/span>) == <\/span>0 <\/span>)
{
    <\/span>\/\/ retrieve watchlist members
    <\/span>oldlist <\/span>= <\/span>CategoryGetSymbols<\/span>( <\/span>categoryWatchlist<\/span>, <\/span>listnum <\/span>);

    <\/span>\/\/ iterate through the list and remove tickers
    <\/span>for ( <\/span>i <\/span>= <\/span>0<\/span>; ( <\/span>sym <\/span>= <\/span>StrExtract<\/span>( <\/span>oldlist<\/span>, <\/span>i <\/span>) ) != <\/span>""<\/span>; <\/span>i<\/span>++ )
    {
        <\/span>CategoryRemoveSymbol<\/span>( <\/span>sym<\/span>, <\/span>categoryWatchlist<\/span>, <\/span>listnum <\/span>);
    }
}

<\/span>\/\/ sample exploration code
<\/span>Filter <\/span>= <\/span>ROC<\/span>( <\/span>Close<\/span>, <\/span>1 <\/span>) > <\/span>3 <\/span>AND <\/span>Volume <\/span>> <\/span>1000000<\/span>;
<\/span>AddColumn<\/span>( <\/span>Close<\/span>, <\/span>"Close" <\/span>);
<\/span>AddColumn<\/span>( <\/span>ROC<\/span>( <\/span>Close<\/span>, <\/span>1 <\/span>), <\/span>"ROC" <\/span>);
<\/span>AddColumn<\/span>( <\/span>Volume<\/span>, <\/span>"Volume" <\/span>);

<\/span>\/\/ check how many times Filter variable was true in the tested range
\/\/ if non-zero value detected, add current symbol to a watchlist
<\/span>if ( <\/span>LastValue<\/span>( <\/span>Cum<\/span>( <\/span>Filter <\/span>AND <\/span>Status<\/span>( <\/span>"barinrange" <\/span>) ) )  )
    <\/span>CategoryAddSymbol<\/span>( <\/span>""<\/span>, <\/span>categoryWatchlist<\/span>, <\/span>listnum <\/span>)<\/code>","protected":false},"excerpt":{"rendered":"

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 […]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[6],"tags":[53,14,28,29],"_links":{"self":[{"href":"https:\/\/www.amibroker.com\/wordpress\/kb\/wp-json\/wp\/v2\/posts\/705"}],"collection":[{"href":"https:\/\/www.amibroker.com\/wordpress\/kb\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.amibroker.com\/wordpress\/kb\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.amibroker.com\/wordpress\/kb\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.amibroker.com\/wordpress\/kb\/wp-json\/wp\/v2\/comments?post=705"}],"version-history":[{"count":2,"href":"https:\/\/www.amibroker.com\/wordpress\/kb\/wp-json\/wp\/v2\/posts\/705\/revisions"}],"predecessor-version":[{"id":708,"href":"https:\/\/www.amibroker.com\/wordpress\/kb\/wp-json\/wp\/v2\/posts\/705\/revisions\/708"}],"wp:attachment":[{"href":"https:\/\/www.amibroker.com\/wordpress\/kb\/wp-json\/wp\/v2\/media?parent=705"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.amibroker.com\/wordpress\/kb\/wp-json\/wp\/v2\/categories?post=705"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.amibroker.com\/wordpress\/kb\/wp-json\/wp\/v2\/tags?post=705"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}