It's possible to convert an enum to string though EnumToString.
What about the reverse operation?
There's an way to convert it back (other than create and function and compare item by item)?
I totally agree with you, the reason doesn't matter at all. :)
But I guess there's no ready-to-use function for this, right? I guess a "switch" statement or the array of strings is the way to go.
The reason matter if you need my advice.
It wasn't meant like that at all. And in fact, sometimes there is really no good reason to do something, even in coding. Someone might just want to see if it can be done a certain way, and who knows, it might end up leading off in a totally new direction, because someone else sees it, and thinks "well maybe if we do it this way instead..." and so on. Stranger things have happened. But you are right, usually there is a reason to code something a certain way.
Back to Henrique:
I do not think a switch would be the ideal solution, and here's why. If you will always just use the exact same enum'd list, yes, this would work. However, if you want your code to be adaptable, without having to re-write it every time the list changes, then I think the for/next would be the way to go. You can code it so it gets the next chunk (separated by something) and write it to string (or possibly back to enum from a string array), and all you would need to do is give the loop the number of items you want to convert. For other things, this would be adaptable as well, to my mind anyway, with minimal coding changes.
Edit: I just thought of something that might make this even more wide range adaptable, and not totally sure about how to code it, just have a grasp of the concept. I know in the OOP language I learned, Java, you can overload functions (make multiple functions with the same name that accept different inputs), but maybe an adaptable version of this idea could work here. Make a function, either within an object or on it's own within the program that takes as inputs, the from, the to, and the number for one side of the function, and on the other side, the exact opposite. Like the from enum to string for one, and the string to enum on the other.
Well to be honest i did struggle with this issue for some time.
As you know the input panel is static, this results in the following, suppose i want to have a broad as possible audience, my EA needs to work with as much currency pairs as possible.
Due to the fact it is static, means that many,many traders using my EA will see a lot of currency pairs in the input settings, that are actually not available on their broker feed, which can lead to confusion.
Had it been possible to StringToEnum() the input settings symbol list in a way that it would only present the available symbols, it would have made a rather large difference when it comes to flexibility and comfort in usage.
This is about the only thing i never got to work properly, i found a solution for every other problem so far, but not the possibility to synchronize the symbol list in input settings with Market watch (1) i just had to accept it was not possible.
You want the users of your EA to choose the symbols the EA has to manage, right ? How a StringToEnum() can help ?
Please give more information about your issue.