Unexpected result using AddTextColumn

For some reason when I run the following 'exploration' I get a 'Yes' on every day whilst only Fridays are in green, can someone please tell me where I'm going wrong...

AddColumn( DayOfWeek(),"Day Of Week",1.0);

AddColumn( DayOfWeek() == 5, "Day of Week Is Friday", 1.2);

AddTextColumn( WriteIf( DayOfWeek() == 5, "Yes", "No" ), "Friday?", 1.0, IIf( DayOfWeek() == 5, colorGreen, colorRed ), colorDefault, 100 );

Filter = 1;

@SippDealer, there is a note in "WriteIf" documentation by TJ that states:

Please note that WriteIf returns just single string representing current SelectedValue of the EXPRESSION

A simple fix is to use the recently (6.20) introduced AddMultiTextColumn function:

AddMultiTextColumn((DayOfWeek() == 5), "No\nYes", "Friday?", 1.0, IIf( DayOfWeek() == 5, colorGreen, colorRed ), colorDefault, 100 );

That's works great thanks!

Still not entirely sure why using 'AddTextColumn' along with 'WriteIf' fails as although I now see the comment about 'the current SelectedValue' I have seen it used numerous times in various explorations?


Please note that AddTextColumn takes single string as a parameter, so you can only display text that does NOT vary on bar-by-bar basis.

I did see that thanks, but as I said, I have seen it used numerous times in various explorations which is why I'm a little confused.

@SippDealer, the WriteIf function as you can see looking at the documentation is a function that was mainly introduced to mimic some MetaStock functionality and is used a lot in the "Commentary" sections code (where it displays a specific text based on the Selected value expression)

When used in explorations, as stated by @awilson, it is commonly employed to display single values (i.e., strings that do not change bar by bar) like the FullName(), the sector/industry names, etc.

This KB article explains it well. In particular, it shows you when you can use it in exploration to display "text" that is based on a certain condition.

On the other hand, the AddMultiTextColumn should be used to display a certain string (selecting it from the passed "TextList") using as indexes the first parameters array values, like in this example that will show the names of the days of the week in Italian:

itDayNames = "Domenica\nLunedì\nMartedì\nMercoledì\nGiovedì\nVenerdì\nSabato";
AddMultiTextColumn(DayOfWeek(), itDayNames, "Giorno", 1.0, IIf( DayOfWeek() == 5, colorGreen, colorBlack ), colorDefault, 120 );

Thanks ever so much for the reply. The KB article explains it very well thanks!