Every week i run exploration and save the results in a Watch List. A feature i was looking for is to find the following - Delta/Difference between 2 or more watch lists. This will help find symbols that are
appearing new for first time in current latest watchlist
appearing again and again in earlier and current watch list
What i mean is a feature to find the following
SYMBOLS present in both ( for 2 watch lists) or all ( more than 2) watch list(s)
SYMBOLS present only in the latest /current watch list.
SYMBOLS absent in the current watch list.
Example:
Watch List 1
A1
A2
A3
Watch List 2
A1
A4
A2
SYMBOLS present in both Watch List 1 and 2 - A1,A2
SYMBOLS added new in Watch List 2 - A4 [ The latest watch is the one specified the last when providing input ]
SYMBOLS absent in current Watch list - A3
A similar feature is provided by the UNIX comm utility. Has anyone attempted any thing of this sort, or can share pointers on how to do this?
Although I have to say I initially misread the SetOption field as "NodeFaultColumns" and it took me a few minutes to realize that it was actually "NoDefaultColumns". (Low on Coffee I guess )
nice one Mr. @fxshrat
By feature i meant not some readymade UI or Straight forward Function that we can call like Unix comm but what i meant is we need to write some code using already available functions.
Here you have nicely shown how we can add two arrays and deduce some output, especially with InWatchListName()
// sum up memberships
memship_sum = mem1 + mem2;
// being present in either watchlist
inWL_either = memship_sum > 0;
// being present in both WLs
inWL_all = memship_sum == 2;
So if you have more Watchlist (or want to check for number of watchlists flexibly) you may write loop like this (for example):
/// Find memberships in defined watchlists.
/// @link https://forum.amibroker.com/t/delta-between-two-watch-lists/24576/8
WL1 = "WL Name 1";// insert your Watchlist1 name
WL2 = "WL Name 2";// insert your Watchlist2 name
WL3 = "WL Name 3";// insert your Watchlist3 name
WL4 = "WL Name 4";// insert your Watchlist4 name
WL5 = "WL Name 5";// insert your Watchlist5 name
WL6 = "WL Name 6";// insert your Watchlist6 name
// etc.
// set number of watchlists to check (see above)
wl_num = 6;
for ( i = 1, memship_sum = 0; i <= wl_num; i++ ) {
inWL = InWatchListName(VarGetText("WL"+i));
VarSet("inWL"+i, inWL);
// sum up watchlist memberships
memship_sum += inWL;
}
// being present in either watchlist
inWL_either = memship_sum > 0;
// being present in ALL WLs
inWL_all = memship_sum == wl_num;
// OUTPUT
SetOption("NoDefaultColumns", True);
SetSortColumns(-(wl_num+2),1);// Sort by inWL_all
Filter = inWL_either AND Status("lastbarinrange");
AddTextColumn(Name(), "Ticker", 1);
False_True = "FALSE,TRUE";
for ( i = 1; i <= wl_num; i++ )
AddTextColumn(StrExtract(False_True,VarGet("inWL"+i)), "In "+VarGetText("WL"+i), 1);
AddTextColumn(StrExtract(False_True,inWL_all), "In ALL watchlists", 1, -1, -1, 150);
NOTE: of course one may use logical operators with loop too... but I didn't.
Anyway... probably being a matter of taste what you do like/prefer more.