any way to store expression into a variable or array? - page 2

 
Fernando Carreiro #:

No, saving the boolean results as a string will make your code very inefficient. There are two options (at least), either use a structure or use use two arrays, one boolean for the condition and another for the expression string for printing.

The second option is using an array of a structure.

Warning! The above code was just typed out in the post. It was not compiled or tested. There may be typos, that need to be checked.

Yes I would normally do it that way - 2 arrays, or a struct in an array along with the required methods, and there are other ways too.

But I was just trying to provide the simplest solution to meet the OP's requirement - I doubt the processing overhead would be significant for such a small array

 
Fernando Carreiro #:

There is also a way of using macros to "stringify" the expression, so that you don't have to type the expression twice. This will help keep the code consistent when you update the expressions.

However, this is a more power programmer coding skill that needs careful planing of the code logic, but you can research the "#" Stringification functionality of the standard C/C++ preprocessor which also works on MQL.

many thanks fernando, 

let me digest your suggestions, which makes a lot of sense.

thanks also to R4na for your suggestions. always learning from you guys.