Watchlist names in Exploration output

_SECTION_BEGIN("Price Volume 20  v");
cond= C> Ref(HHV(C,20),-1);
Filter= cond;
AddColumn(C,"Price", 1.2);
cond= C> Ref(HHV(C,20),-1) AND V> Ref(V,-1)*1.2;
Filter= cond;
AddColumn(C,"Price", 1.2);
AddColumn(V,"Vol",1.2);
_SECTION_END();

Can you clarify what you are trying to do? Your code is for an exploration. Are you asking for a way to:

  1. Run this exploration on a particular watchlist (using AFL instead of the Exploration user interface).
  2. Add a column containing the watchlist name(s) a listed ticker is a member of
  3. Add a column listing the watchlist name(s) that are part of the current filter.

Yes Sir,
You are perfect, by using this code I am trying to find out price and volume for particular period by using exploration.
And I have more than 70+ watch list based on verticals or busyness & financial data.
On NSE exchange there are more than 2000+ odd stocks from different verticals(Sectors/Business ) like Tyre , Cement , consumables, IT , Banking etc.
Due to above code I can find out price and volume change in particular period but can’t make out from which specific sector that stock is form because I am choosing Apply to all scripts and Date range, not for a use fileter as a particular watch list.
This will help me to find out which sector is performing based on my current exploration criteria.12

@prakashmodak It’s a pity, that you don’t want to learn even basics of AFL. I’ve already provided you with some example codes:

Besides it looks like you are using some ancient version of AB - 5.4x or older. Am I right? The new Analysis window was implemented in AB 5.50 in the year 2011! Versions lower than 6.0 are not supported on this forum. Is it a legal copy? Have you been using Amibroker since 2011 without knowing basics of AFL?

Yes I am using 5.60 versions which is licence copy,
its legal copy.
I did not know that this forum is not supporting older versions.
If this license is not supporting this forum I will go for latest version.
No problem.
but can it will solve my problem?
l

I answered to that already over support channel I think.
The answer was that one symbol can belong to MORE than one watch list at a time (actually to unlimited number of watch lists).

You can check if symbol belongs to given watch list using AFL functions
http://www.amibroker.com/f?inwatchlist
http://www.amibroker.com/f?inwatchlistname

This gives “true” result when symbol belongs to given watch list.

@prakashmodak, since you plan to upgrade, I’m posting this code snippet to reward your good will, but… you should learn ASAP to program basic.AFL as suggested in the previous answers.

Actually, to write this code, I followed @Milosz precious suggestions: you should have done the same since the was already a piece of code by @fxshrat that does what you want.
Here in the forum there are some VERY talented coders that will help you to learn how to code (start from this thread) but to get answers you should do a serious effort to study the basics, read the forum topics, search for already posted solutions and then, if still lost, request help here!

/// Based on code posted on the forum by fxshrat
/// @link http://forum.amibroker.com/t/how-to-find-out-the-ordinal-number-or-name-of-the-watchlist-in-which-symbol-is-being-dispalyed/1590/3

// This function return a string that includes all the numbers and names of 
// the watchlists that include the currently selected ticker in the format:
// #, WLName; #, WLName; #, WLName; etc. (# is the WL ordinal) 
function getWLList(start, end)
{
    wlstr = "";
    category = categoryWatchlist;
    for( i = 0; CategoryGetName( category, i ) != ""; i++ )
    {
        if( InWatchList( i ) )
        {
            catname = CategoryGetName( category, i );
            if( wlstr != "" )
            {
                wlstr = wlstr + "; ";
            }
            wlstr += WriteVal( CategoryFind( catname, category ), 1 ) + ", " + catname;
        }
    }
    return wlstr;
}



cond = C > Ref( HHV( C, 20 ), -1 ) AND V > Ref( V, -1 ) * 1.2;
Filter = cond;
AddColumn(C, "Close");
AddColumn(V, "Volume");
AddTextColumn(getWLList(), "WL", 1.2, colorDefault, colorDefault, 400);
SetSortColumns(5);

Keep in mind that this code could be slow (it needs to parse a lot of strings).
This code could be improved, but probably it is enough for your usage.

6 Likes

@prakashmodak I'm sorry for suspecting you of being illigal AB user - I'm glad, that you are not. But you are using an ancient AB version, which is not supported here. I really encourage you to update it to the newest release - it is really worth it for many different reasons.

@beppe was a little faster :wink: but you can also try my code. It should be a little faster because it performes demanding operations only for the Symbols meeting the Filter criteria:

WatchListsStr = "";
Category = categoryWatchlist;

Filter = C > Ref( HHV( C, 20 ), -1 ) AND V > Ref( V, -1 ) * 1.2;

if( LastValue( Filter ) )

{
    for( i = 0; CategoryGetName( category, i ) != ""; i++ )
    {
        if( InWatchList( i ) )
        {
            CategoryName = CategoryGetName( Category, i );
            WatchListsStr += CategoryName + ",  ";
        }
    }

}

AddColumn( C, "Price", 1.2 );
AddColumn( V, "Vol", 1.2 );
AddTextColumn( WatchListsStr, "Watch Lists", 1.2, colorDefault, colorDefault, 500 );

Watchlists Exploration

3 Likes

I cannot edit my prior post, but I forgot to mention, that an inspiration for me was the code provided by @fxshrat in this post:

@prakashmodak please note, as was reported to me by @Milosz and @Panos (thanks!), that in my previous code **there is an error. **

The start of the function should be:

function getWLList()
{
    wlstr = "";

No parameters (I was modifying it to use a range of watchlists to search for, but then decided to simplify it and I forgot to remove the parameters when posting it). Sorry.

But since @Milosz code is probably faster you better use that!

Sir,

Thanks a Ton !!!

Its working fine as per my expectation.

Actually I thing this AFL is finding price increasing (from to days) and as well as volume is also increasing meant some big hands are accumulating this.

Am i right?

Thanks again.

Regards,

Thanks a Ton! after changing the function its working fine.

if i want to contact on you on email rather than forum is it possible?

i am new to this forum so asked.

This is just what I needed! Thank you!