WriteIf is working AS DOCUMENTED, was: not working as I expect


AddTextColumn( WriteIf(IFU,"Up","Down"), "Index", 1.3, IIf(IFU,colorGreen,colorRed), 2, 40);

I see this:
2020-08-03 15_45_39-AmiBroker - Analysis3
The items boxed in red should display 'Up' and not 'Down' I believe. Where am I going wrong with the text output for WriteIf(IFU,"Up","Down") ?

WriteIf only returns single string for current selected value.

See WriteIf.

1 Like

There is no array of strings in AFL

But you may use AddMultiTextColumn to output string on array in Explorer.


IFU = C > MA(C,20);

Filter = 1;

// if IFU returns 0 or 1
AddMultiTextColumn(IFU,"Down\nUp", "Index", 1.3, IIf(IFU,colorGreen,colorRed), 2, 40);

Did you read the manual:

It very clearly says:

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

Yes. I did not know what that meant.

To me it made sense, as IFU returns a value for every row in the Exploration, that a function that consumes IFU should do the same, but it does not. I am more familiar with the C# and T-SQL; AFL is different. Hence the #newbie tag on this post.