Download MetaTrader 5
To add comments, please log in or register
Sign up to publish an article and receive 200 USD
houmer
950
houmer 2015.05.29 15:04 

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 

Drazen Penic
2538
Drazen Penic 2015.05.29 15:16  

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

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

houmer
950
houmer 2015.05.29 16:43  
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 :-/ 
Vladimir Karputov
Moderator
45421
Vladimir Karputov 2015.05.29 17:55  
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?
houmer
950
houmer 2015.06.01 11:42  
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 ... 

 

Vladimir Karputov
Moderator
45421
Vladimir Karputov 2015.06.01 13:10  

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).
Ex Ovo Omnia
3110
Ex Ovo Omnia 2015.06.01 15:18  
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
houmer
950
houmer 2015.06.01 15:43  
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 :-) 

/
To add comments, please log in or register