ENUM Symbol list as an INPUT

 

Hi, I am going to do following:

I want to have symbol as an input parameter, so I want an input variable (enum) from which I will choose the right symbol, like this:

I have done this by this code:

enum ENUM_SYMBOL
   { 
    EURUSD=0, 
    GPBUSD=1, 
    USDCHF=2
   };

That works for me perfectly. But I would like to fullfill the enum dynamicaly by the whole list of symbols (SymbolsTotal(0);).

Somehow probably by code:

int a = SymbolsTotal(0);
for(int i=0; i!=a;i++){
....
}


Do you know how to do that?

Thanks a lot.

 

Run the EA in Terminal (!= Tester)

enum ENUM_SYMBOL
 { 
  EURUSD= 0 , 
  GPBUSD= 1 , 
  USDCHF= 2
 };

input ENUM_SYMBOL Symbol;
   
void OnInit()
{
  ChartSaveTemplate(0, __FILE__); // tpl-file
}


tpl-file:

<expert>
name=Test
path=Experts\Test.ex5
expertmode=0
<inputs>
Symbol=0
</inputs>
</expert>

The enumeration is contained in the source, unfortunately.


Real input-types: long, double and string.

 
Martin Nohejl:

I want to have symbol as an input parameter, so I want an input variable (enum) from which I will choose the right symbol, like this:


Your option is to develop a custom settings panel for your EA. This way you can populate input parameters dynamically. Standard EA settings dialog does not support this.

 
Stanislav Korotky:

Your option is to develop a custom settings panel for your EA. This way you can populate input parameters dynamically. Standard EA settings dialog does not support this.

Please can you give me a link to some guide?
 
Martin Nohejl:
Please can you give me a link to some guide?

You can start from this article or this article or this article. Feel free to search for "panel" in the code base as well. There are panels and controls in the standard library.

 

here is the solution.

enum ENUM_SYMBOL {

   Current = 0,

   USDJPY_i,

   NZDUSD_i,

   CADJPY_i,

   USDCAD_i,

   WSt30_m_i,

   //LTCUSD_i,

   //USDRUR,

   //USDRUR_i,

   //XRPUSD_i,

   EURNZD_i,

   XBNUSD_i,

   USDCHF_i,

   BTCUSD_i,

   GBPUSD_i,

   GER40_m_i,

   XAGUSD_i,

   HSI50_i,

   ETHUSD_i,

   XAUUSD_i,

   EURCHF_i,

   SPX500_m_i,

   NQ100_m_i,

   EURUSD_i,

   AUDUSD_i,

   GBPJPY_i,

   GBPCAD_i,

   EURCAD_i,

   GBPCHF_i,

   NZDCAD_i,

   EURGBP_i,

   AUDCAD_i,

   EURAUD_i,

   AUDNZD_i,

   EURJPY_i,

   CADCHF_i,

   AUDCHF_i,

   NZDJPY_i,

   GBPAUD_i,

   AUDJPY_i,

   CHNA50_m_i,

   GBPNZD_i,

   CHFJPY_i,

   ASX200_i,

   CAC40_i,

   STOXX50_i,

   NQ100_i,

   NFTY50_m_i,

   GBPSGD_i,

   NZDCHF_i,

   GER40_i,

   FTSE100_i,

   SPX500_i,

   NIKK225_i,

   IBEX35_i,

   WTI_i,

   BRN_i,

   NG_i,

   //_BTCEUR,

   //_DXY,

   //USDDKK_i,

   //USDSGD_i

};

input ENUM_SYMBOL SelectedSymbol;

string getSymbol()

{

   if(SelectedSymbol == Current)

      return _Symbol;

   return EnumToString(SelectedSymbol);

}



now use function getSymbol to read the selected symbol by tester