StringToEnum - page 2

 
In my understanding enum is a uint representing the index of a list (with holes) of the 'names' of an enum.
You are always dealing with the uint either by the value itself or by using the enum-'names'.
But like the name of a defined value (e.g. #define OP_BUY 0) you can't get the name 0 or do you know how to print OP_BUY instead of 0?
If you want to print the names of the the enum you have to create a string array str[] so that str[e] = 'name'.
 
calli:
In my understanding enum is a uint representing the index of a list (with holes) of the 'names' of an enum.
You are always dealing with the uint either by the value itself or by using the enum-'names'.
But like the name of a defined value (e.g. #define OP_BUY 0) you can't get the name 0 or do you know how to print OP_BUY instead of 0?
If you want to print the names of the the enum you have to create a string array str[] so that str[e] = 'name'.
Would it be possible to pull the names out as a full string for each name, or would you have to parse it out and make each full name an array of chars, and then reform the completed name from the array(s)?
 
Alain Verleyen:

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.

No i want the input setting list to only show the available symbols, do you have a solution for that?
 
Marco vd Heijden:
No i want the input setting list to only show the available symbols, do you have a solution for that?

One possible solution I see is to release EA 'flavors', for each broker. It can be rigorous though because you have to redefine enums for each of them. However, you can narrow it down to  your own list of 'recommended' brokers/broker feeds.

Another (less rigorous) solution is to use a GUI panel with a combobox displaying a list of available symbols for the broker. This would create an additional settings window for your users, but at least, you'll only have a single EA to support all brokers and your users would only able to see the symbols that their broker supports.

 
Enrico Lambino:

Another (less rigorous) solution is to use a GUI panel with a combobox displaying a list of available symbols for the broker. This would create an additional settings window for your users, but at least, you'll only have a single EA to support all brokers and your users would only able to see the symbols that their broker supports.

Yes i have many EA's that show a GUI with only the symbols found on the broker feed this was the only thing i could come up with, but then another problem arises as you will not be able to save the settings as a .set file which means you have to set up the entire thing over and over again when you reload the expert.

If i were to produce a separate EA for different brokers, then there is a problem for selling it in market, i am unaware of a 'pick your broker' function in market.

The best solution so far for me was to add as much symbols as possible to the input settings, then copy these values to the GUI settings, then the GUI always pops up with the input settings meaning you would have to adjust and save them only once, and the GUI would always only show the available symbols.

 
Marco vd Heijden:

Yes i have many EA's that show a GUI with only the symbols found on the broker feed this was the only thing i could come up with, but then another problem arises as you will not be able to save the settings as a .set file which means you have to set up the entire thing over and over again when you reload the expert.

It is possible to have a panel have a 'save' and 'load' option. All panel controls are descended (indirectly) from CObject, which has these methods. You will need to override them by defining another class which inherits from the class of the original controls. However, depending on your EA, this can be a great deal of work. Also, the files can only be saved under the 'Files' folder, but it is possible to load them in a way similar to set files.

Marco vd Heijden:

The best solution so far for me was to add as much symbols as possible to the input settings, then copy these values to the GUI settings, then the GUI always pops up with the input settings meaning you would have to adjust and save them only once, and the GUI would always only show the available symbols.

Saving a *.set may be easier. I do not have the complete picture of the EA, but I am guessing that you have boolean parameters on the expert properties window. Or possibly a string input parameter on the expert properties window, containing a list of symbols your users would like the EA to trade on, parse them, and then store them in a string array. This gives you three arrays:

  1. Your own list (EA can trade on)
  2. Your user's list
  3. The broker's list of the user
If you get the intersection of these three arrays, then you will get the correct list of symbols to display on the panel (not sure if you are using a check group orcombo box, or other controls). Alternatively, you can also introduce a parameter that lets the user opt out of having his own list, so he gets the symbols both his EA and his broker can possibly support.
 

Thanks Enrico

I will try to improve on this.

Here is a image of the expert settings panel to illustrate the problem.

Expert Settings

Funny thing is i had to resize it to 50% because it was too large to post to this forum.

 
Marco vd Heijden:
No i want the input setting list to only show the available symbols, do you have a solution for that?

You already know it's not possible. The input parameters are hardcoded at compile time into the .ex4/5, the available symbols are only known at run time.

Metaquotes only can propose a solution for the input parameters.

To remain on topic, I don't see how your problem could be resolved with an StringToEnum function ?

 

Yes you are right i hoped to find a solution where it was possible to insert a drop down enum list into the EA's input parameter list, that would only show the available symbols.

If it was possible to

enum symbols
{
 SymbolsTotal(i,1)
};

or

for(int i=0;i<SymbolsTotal(1);i++)     
 {
  StringToEnum(SymbolName(i,1)=i,//yeah
 }      

or a vague combination of all this to make sure there is no symbol overload in the settings.

It's just that you said you didn't see any usage for such a function so i gave this example.

Of course i know it's not possible but that is the point of not having this functionality, to find solutions.

 
Marco vd Heijden:

Yes you are right i hoped to find a solution where it was possible to insert a drop down enum list into the EA's input parameter list, that would only show the available symbols.

If it was possible to

or

or a vague combination of all this to make sure there is no symbol overload in the settings.

It's just that you said you didn't see any usage for such a function so i gave this example.

Of course i know it's not possible but that is the point of not having this functionality, to find solutions.


Ok, thanks, I get your point now. What you would like is to build an ENUM dynamically, which I think is not what the OP want.

enum symbols
  {
   EURUSD = 1,
   AUDUSD = 2,
   GBPUSD = 3   
  }; 
  
string mysymbol="AUDUSD";

// OP : How to get '2' from string "AUDUSD" ?
There is a lot of improvements on Input parameters which could be useful, hopefully Metaquotes will do them one day.
Reason: