ENUM char -

 

Please, 

do you know how can I add to the ENUM list values string with - char ?

 

I want this code:

 

enum ENUM_SYMBOL_LIST          // List of symbols

  { 

    EURUSD,          // This is OK value

    AUDCAD,         // This is OK value

    GOLD,             // This is OK value

    CORN-JUL15,   // This is ERROR value '-' - comma expected 

    GSOIL-JUN15   // This is ERROR value '-' - comma expected 

  };

 

Thank you very much 

 

"-" minus is reserved for subtractions, you can't use it in a variable or enum name.

You can use underscore "_" - it's close enough. 

 
Drazen Penic:

"-" minus is reserved for subtractions, you can't use it in a variable or enum name.

You can use underscore "_" - it's close enough. 

It"s not good message for me :( My broker use "-" in symbol names :-/ 
 
houmer :
It"s not good message for me :( My broker use "-" in symbol names :-/ 
Use the "-" sign in the ENUM can not. Why is this design? What do you like to do?
 
Karputov Vladimir:
Use the "-" sign in the ENUM can not. Why is this design? What do you like to do?
I use this code for create list box at Input values form, but because symbol names  contains - I can not fill all names on enum :-/

.. Other code ...

enum ENUM_SYMBOL_LIST          // List of symbols
 { 
    EURUSD,
    AUDCAD,
    GOLD,
    CORN-JUL15,
    GSOIL-JUN15
  };
input ENUM_SYMBOL_LIST InpSymbol=EURUSD;  // User selecting symbol name

...... Other code ......
MqlTradeRequest request = {0};
request.action = TRADE_ACTION_DEAL;
request.magic = 777;
request.symbol = EnumToString(InpSymbol);     // Used user selected symbol name from listbox 
request.volume = 0.01; 
request.sl = 0;
request.tp = 0;
request.type = 1;
MqlTradeResult result={0};
OrderSend(request,result);

... Other code ... 

 

 

I think you do not need to use an enumeration. You should:

  1. Fill list
  2. When sending a request to extract from the list of text (Value).
 
houmer:
I use this code for create list box at Input values form, but because symbol names  contains - I can not fill all names on enum :-/

.. Other code ...


...... Other code ......

... Other code ... 

 

enum ENUM_SYMBOL_LIST          // List of symbols
 { 
    EURUSD,                   // EURUSD
    AUDCAD,                   // AUDCAD
    GOLD,                     // GOLD
    CORN_JUL15,               // CORN-JUL15
    GSOIL_JUN15               // GSOIL-JUN15

  };
input ENUM_SYMBOL_LIST InpSymbol=EURUSD;  // User selecting symbol name
 
Ovo Cz:

Thank you very much, I will use enum with "_" and in traderequest a will use before EnumToString() to new string variable .. and after I will use StringReplace() for change from "_ " to  "-".

Thanks everybody :-)

 

P.S.:Perhaps it is a pity that does not MQL5 enum containing the names of symbols from trade, this would facilitate the work :-)