Colour Names in a list

I would like to see these symbols in green in a list. How can I program this issue? Thanks for any advice

sym1 = ParamStr("1st Symbol", "ZM");
sym2 = ParamStr("2st Symbol", "K");
sym3 = ParamStr("3st Symbol", "AAPL");
sym4 = ParamStr("4st Symbol", "JNJ");
sym5 = ParamStr("5st Symbol", "MELI");
sym6 = ParamStr("6st Symbol", "NVDA");
sym7 = ParamStr("7t Symbol", "JD");
sym8 = ParamStr("8st Symbol", "AMD");

// this is wrong
AddTextColumn( FullName(), "Full name", 77 , colorDefault, IIf(Name() == sym1,colorGreen, IIf(Name() == sym2,colorGreen, IIf(Name() == sym3,colorGreen, colorDefault ) )));

Hello

The code looks ok.
But you maybe forgot one of below 2 steps

  1. Did you know that FIRST you must press parameters icon before you press the exploration button in AAnalysis window, If you want to chance them?

  2. Also in your code you forgot to write the Filter

// insert a filter of your preference to see the results in AA analysis window

Filter=1;  

Note that Parameters are INDEPENDENT for each chart pane and for Automatic Analysis window.
In Automatic Analysis window parameters can be modified using "Parameters" button and they are independent from ones you use for any chart.

thanks for the reply. Any idea how can I colour a certain symbol if a certain rank is reached

AddTextColumn( FullName(), "Full name", 77 , colorDefault, IIf(sym=`AAPL` and rank>=50,colorRed,colorDefault ) )

Hello

Sorry but you didn’t tell us if you solve and how you solve your first question.

For example if the filter for the exploration was missing, then how we know if something else is missing for the rank code if we donot see your code?

Anyway as I can see this single afl line look ok, and you should see the colours. I guess somewhere else is your problem, you may send here in the forum the code with the rank.

Unless the quotes are wrong

// IIf(sym=`AAPL`   << wrong quotes

//  should be as 
IIf(sym= "AAPL"

It is three things (resulting in syntax errors):

  1. Incorrect quotes
  2. @Munichtrader used assignment operator = instead of equality operator ==
  3. And forgot semicolon at the end of line

->

bk_color = IIf(sym == "AAPL" AND rank>=50,colorRed,colorDefault );
AddTextColumn( FullName(), "Full name", 1, colorDefault, bk_color );

For testing:

Filter = BarIndex() >= BarCount-2;
rank[BarCount-1] = 51;
rank[BarCount-2] = 10;
bk_color = IIf(Name() == "AAPL" AND rank>=50,colorRed,colorDefault );
AddColumn( rank, "Rank", 1 );
AddTextColumn( FullName(), "Full name", 1, colorDefault, bk_color );

15

I am working with StaticVarGenerateRanks. The green work but not red . The above example works. What do I wrong here.

sym1 = ParamStr("1st Symbol", "IBM");
sym2 = ParamStr("2st Symbol", "GE");
sym3 = ParamStr("3st Symbol", "JNJ");
sym4 = ParamStr("4st Symbol", "T");
sym5 = ParamStr("5st Symbol", "MELI");
sym6 = ParamStr("6st Symbol", "NVDA");
sym7 = ParamStr("7t Symbol", "JD");
sym8 = ParamStr("8st Symbol", "MSFT");


bk_color = IIf(Name() == sym1 OR Name() == sym2 OR Name() == sym3 OR Name() == sym4 OR Name() == sym5 
OR Name() == sym6 OR Name() == sym7 OR Name() == sym8  AND rank>=50,colorRed,colorDefault );

Filter = 1;

AddTextColumn( FullName(), "Full name", 77 , colorDefault, IIf(Name() == sym1 or Name() == sym2 or Name() == sym3 or Name() == sym4 or Name() == sym5 or Name() == sym6 or Name() == sym7 or Name() == sym8,colorGreen,bk_color ) );
 
 

 

You have no brackets before first and after last OR component

(Name() == sym1 OR Name() == sym2 OR Name() == sym3 OR Name() == sym4 OR 
Name() == sym5 OR Name() == sym6 OR Name() == sym7 OR Name() == sym8) AND rank>=50

But instead of using OR/AND you can just do this:

sym1 = ParamStr("1st Symbol", "IBM");
sym2 = ParamStr("2st Symbol", "GE");
sym3 = ParamStr("3st Symbol", "JNJ");
sym4 = ParamStr("4st Symbol", "T");
sym5 = ParamStr("5st Symbol", "MELI");
sym6 = ParamStr("6st Symbol", "NVDA");
sym7 = ParamStr("7t Symbol", "JD");
sym8 = ParamStr("8st Symbol", "MSFT");

// https://forum.amibroker.com/t/colour-names-in-a-list/22868/8
sym_list = ",";
for( i = 1; i <= 8; i++ )	sym_list += VarGetText("sym"+i)+",";	
sym_cond = StrFind(sym_list, ","+Name()+",");	

if ( sym_cond ) 
	bk_color = IIf(rank>=50, colorRed, colorGreen);
else
	bk_color = colorDefault;

Filter = 1;

AddTextColumn( FullName(), "Full name", 1, colorDefault, bk_color );

Awesome, asking questions... zero response.

1 Like

@fxshrat - sometimes people need to get some sleep. Don't worry, just give some more time.

Munich time 12:39 P.M. (3 hours ago).
Old saying "Early bird catches the worm".
Noon is too late for that.

Besides sent private message asking for specifics about "this is wrong" is 3 days old. That's lots of sleep. :wink:

15

woke up thanks it is chrismas time thanks :smiley:

This topic was automatically closed 100 days after the last reply. New replies are no longer allowed.