How to get the chart symbol through AFL

Hi,

How to read the symbol in AFL. I need to apply Buy/Sell conditions if the symbol matches.

something like below

if (symbol='apple')
{
Buy=(some conditions);
Sell =(some conditions);

}

How to achieve this in AFL?

Thanks in advance.

Use code tags for all the code posted. Its a Forum rule.

See Name()
https://www.amibroker.com/guide/afl/name.html

And use "apple" double quotes for string, not single when comparing ==.

Thanks @travick . I have symbols in my watch list. The symbols are categorised in
1)List A 2) List B 3) List C

So i need to write the if condition like this below.

If (name() belongs to ListA)
{
  Buy=(some conditions);
 Sell =(some conditions);

}
else if(name() belongs to ListB)
{
Buy=(some conditions);
Sell =(some conditions);

}

How to write in AFL.

Thanks in advance.

Search the forum, there are plenty of examples of reading and writing symbols to/from watchlist.
Also to check if symbol is present etc

No need to re-invent the wheel.

Can any one share the link for getting sample code to achieve my criteria .i.e reading symbols from watch list

@Kum001,

Did you not see this?

1 Like

You do not need to read/write from/to Watchlist (file) for that.
Writing to watchlist? What for?

All you need are inbuilt functions to verify watchlist membership...
either function InWatchlist(...) or InWatchListName(..)

If (InWatchlist(0)) // insert watchlist number to function
{
  Buy = (some conditions);
  Sell = (some conditions);
}

if (InWatchlist(1)) // insert watchlist number to function
{
  Buy = (some conditions);
  Sell = (some conditions);
}

Or

If (InWatchlistName("List 1")) // insert watchlist name to function
{
  Buy = (some conditions);
  Sell = (some conditions);
}

if (InWatchlistName("List 2"))// insert watchlist name to function
{
  Buy = (some conditions);
  Sell = (some conditions);
}
2 Likes

Thanks @fxshrat. Got the solution.