IIF for the string?

I want to change the message_string as below:

ma1 = MA(C, 10);
ma2 = MA(C, 30);
Cross_over = Cross(ma1, ma2);
message_string = IIf ( Cross_over, "do_long", "do_nothing");

but I don't know what is the correct function to call, please help,
Thank you very much :smiley: !

@alexlin,

See WriteIf and AddTextColumn.

Thank you :slightly_smiling_face:!
Actually WriteIF return a string, not array (I need an array).
...
Also you can try code below:

ma1 = MA(C, 10);
ma2 = MA(C, 30);
Cross_over = Cross(ma1, ma2);
message_string = WriteIf ( Cross_over, "do_long", "do_nothing");
AddTextColumn( message_string, "message");

then you will see all rows on the 'message' column will be all the same.
(it means that this question does not be solved).

See AddMultiTextColumn.

1 Like