Problems with multiply enum's

 

Hello everyone,

How should I program this?  

I can't see a way to get string "sym" to receive more than one enum value.

Example:

METAL selection is only Gold, or Silver

AUD selection  is only AUD vs other pairing

EUR selection  is only EUR vs other pairing

GBP selection  is only GBP vs other pairing

USD selection  is only USD vs other pairing

void Testing()
{ 
//enum metal{GOLD,SILVER};
//         input metal METAL;
         
//enum aud{AUDCAD,AUDCHF,AUDJPY,AUDNZD,AUDUSD};
//        input aud AUD;
       
//enum eur{EURAUD,EURCAD,EURCHF,EURCZK,EURDKK,EURGBP,
//         EURHKD,EURHUF,EURILS,EURJPY,EURMXN,EURNOK,
//         EURNZD,EURPLN,EURRON,EURRUB,EURSEK,EURSGD,
//         EURTRY,EURUSD,EURZAR};
//         input eur EUR;
        
//enum gbp{GBPAUD,GBPBGN,GBPCAD,GBPCHF,GBPCZK,GBPDKK,
//         GBPHKD,GBPHUF,GBPJPY,GBPNOK,GBPNZD,GBPPLN,
//         GBPRON,GBPSEK,GBPSGD,GBPTRY,GBPUSD,GBPZAR};
//         input gbp GBP;
        
//enum usd{USDBGN,USDCAD,USDCHF,USDCZK,USDDKK,USDHKD,
//         USDHUF,USDILS,USDJPY,USDMXN,USDNOK,USDPLN,
//         USDRON,USDRUB,USDSEK,USDSGD,USDTRY,USDZAR};
//         input usd USD;
//-------------------------------------------------+

// 'EnumToString' - wrong parameters count      
//  implicit conversion from 'number' to 'string'
 
  string sym = EnumToString (METAL,AUD,EUR,GBP,USD);  
                                                     
   charts = Curr;
   Curr = sym;
   CurrBid         = MarketInfo(Curr,      MODE_BID);
   CurrAsk         = MarketInfo(Curr,      MODE_ASK); 
   CurrentADX      = iADX(Curr,5,14,       PRICE_OPEN,MODE_MAIN,0);
   READminus       = iADX(Curr,5,14,       PRICE_OPEN,MODE_MINUSDI,0);  
   READplus        = iADX(Curr,5,14,       PRICE_OPEN,MODE_PLUSDI,0);
   A_CurrentADX    = iADX(Curr,5,14,       PRICE_CLOSE,MODE_MAIN,0);
   A_READminus     = iADX(Curr,5,14,       PRICE_CLOSE,MODE_MINUSDI,0);  
   A_READplus      = iADX(Curr,5,14,       PRICE_CLOSE,MODE_PLUSDI,0);
   CurrentSignal   = iMACD(Curr,0,12,26,9, PRICE_OPEN,MODE_MAIN,0);
   CurrentValue    = iMACD(Curr,0,12,26,9, PRICE_OPEN,MODE_SIGNAL,0);      
   A_CurrentSignal = iMACD(Curr,0,12,26,9, PRICE_CLOSE,MODE_MAIN,0);
   A_CurrentValue  = iMACD(Curr,0,12,26,9, PRICE_CLOSE,MODE_SIGNAL,0);  
   A_CurrentiMA    = iMA(Curr,15,5,5,      MODE_SMA,PRICE_CLOSE,0);
   CurrentiMA      = iMA(Curr,15,5,5,      MODE_SMA,PRICE_OPEN,0); 
   } 
//+------------------------------------------------------------------+
 
GrumpyDuckMan: I can't see a way to get string "sym" to receive more than one enum value.
  string sym = EnumToString (METAL,AUD,EUR,GBP,USD);  
  1. Of course not. EnumToString takes a single variable (of an enumeration type.)
  2.    Curr = sym;
       CurrBid         = MarketInfo(Curr,      MODE_BID);
    This makes no sense. If sym is a list, you can't pass it to MarketInfo. Just pass each symbol.
    enum metal{GOLD,SILVER};
             input metal METAL;
    enum aud{AUDCAD,AUDCHF,AUDJPY,AUDNZD,AUDUSD};
             input aud AUD;
    :
    do_sym(EnumToString(METAL) );
    do_sym(EnumToString(AUD) );
    :
    

  3. I recommend
    Do not trade multiple currencies in one EA
 

Thank you whroder1,

I would have really liked that to work. I didn't want to use enum with all the pairs mixed together in the one enum.

 
GrumpyDuckMan:

Thank you whroder1,

I would have really liked that to work. I didn't want to use enum with all the pairs mixed together in the one enum.

It looks like you want to iterate through a set of string values.

I am not sure why you (but not only you, it appears quite often here) attempt to use enum in place of a set or an array. Enum is a type definition, derived from the int type. It is not suitable for listing or iterating through its definition values. You do not use the enum as a type, which is the purpose of enum, but rather as a kinda set of string values.

You should create the string (or char) arrays and pass them and iterate them using the for loop.

 

Thanks Ex Ovo Ommia,

In the meantime I have been thinking about #include. I see a possible use of (#include <controls/ComboBox.mqh>) in my EA.

1) Have I over stepped the line.

2)  Is it going to work.

ComboBox = Metal,etc

Reason: