I am using code from help to save explore results to watchlist, but the stocks in the list are not saved when i exit, i tried to find a function call to save the results but couldn't. I saved before exiting, that too didnt work.
What can i do to save the watchlist contents?
listnum = 29; // 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 );
}
}
Diff = abs(UB-LB);
FC1 = Diff / pp < 0.001; // previous value was .001
FC2 = Close > 50;
FC3 = MA(V, 10) > 1000000;
Filter = FC1 AND FC2 AND FC3;
AddColumn(High, "High", 1.2);
AddColumn(Low, "Low", 1.2);
// 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 );
Are you saying that after you run your AFL script there are multiple symbols in that particular watchlist and then when you close and re-open AmiBroker that same watchlist symbols have changed?
@erukumk, please, verify that when setting the "filter" for your exploration you are using DIFFERENT watchlist than the one assigned to listnum (in your example #29).
Anyway, the easiest way to clear and save exploration results is using the "batch" functionalities that were added to Amibroker in 2019 (specifically CHANGES FOR VERSION 6.31.0)
@erukumk, modify your formula to include ONLY the lines used to create an exploration (delete the logic to clear/add to a watchlist). Apply it to the exploration and set the required parameter/filter etc.
Run the exploration and be sure that the report is listing all the symbols you expect.
Then "Save as" the exploration and its current settings settings as a new "project" (.apx).
Then create/modify a "batch" (.abb) including the following steps:
"Load Project" (select the saved project)
"Explore"
"Clear watch list" (enter the number of the watchlist you want to reset)
"Add results to watch list" (enter again the number of the watchlist you want now to fill)
@TrendSurfer This is the first time i am trying to add explore results to a watchlist, i did not use batches too earlier. No other AFL is interfering with this watchlist too.