Change an indicator's value with drop down menu based on pair

 

Is it possible to create a drop down menu that shows you available pairs and changes an indicator's values depending on what pair you pick from the EA settings drop down menu?

Would that be variables? I haven't even tried messing with variables yet as I don't understand what that's about. I only messed with Constants so far. But logically, I can see how this could be done if I knew how to do it. IF it even is possible.

Like If I drop an EA onto XAUUSD and pick that pair in a drop down menu, ATR will change to 3. If I drop it on GBPJPY, I would choose that piar in the drop down menu and it would change to the ATR value best for that pair.


I was trying to do this in fxDreema but I don't see a way. I'm open to using meta editor and doing it manually, if possible.

 
Nicholas: Is it possible to create a drop down menu that shows you available pairs and changes an indicator's values depending on what pair you pick from the EA settings drop down menu? Would that be variables? I haven't even tried messing with variables yet as I don't understand what that's about. I only messed with Constants so far. But logically, I can see how this could be done if I knew how to do it. IF it even is possible. Like If I drop an EA onto XAUUSD and pick that pair in a drop down menu, ATR will change to 3. If I drop it on GBPJPY, I would choose that piar in the drop down menu and it would change to the ATR value best for that pair. I was trying to do this in fxDreema but I don't see a way. I'm open to using meta editor and doing it manually, if possible.

Please stop using "fxDreema". It generates bad code and you don't learn how to code properly.

I'm not exactly sure what you are asking, but if it is just about creating a drop-down list, then define an enumerator (enum) and use it for the input parameter of the EA.

Here is an example:


// Define an enumerator for the input
   enum ESymbolList
   {
      E_EURUSD = 0,  // EUR/USD
      E_EURGBP,      // EUR/GBP
      E_USDJPY       // USD/JPY
   };

// Define a string array of symbol names for the enumerator
   string g_asSymbolList[] = { "EURUSD", "EURGBP", "USDJPY" };

// Declare a drop-down list input
   input ESymbolList i_eSymbolSelect = E_EURUSD; // Select a symbol from the drop-down list

// Declare a global variable to hold selected symbol
   string g_sSymbolName;   // Selected symbol name

// Initialisation event handler
   int OnInit(void)
   {
      // Get symbol name for selected symbol input
         g_sSymbolName = g_asSymbolList[ i_eSymbolSelect ];
         
      return INIT_SUCCEEDED;  // Successful initialisation
   };
 
Fernando Carreiro #:

Please stop using "fxDreema". It generates bad code and you don't learn how to code properly.

I'm not exactly sure what you are asking, but if it is just about creating a drop-down list, then define an enumerator (enum) and use it for the input parameter of the EA.

Here is an example:


Understandable. I just started coding. The last coding experience I had was creating CSS and HTML code in a web programming class over a decade ago!

Thank you for your help, It's actually spot on I think.

Just to verify we're both on the same page and that's what I need, what I'm trying to do is change the X parameter of ATR value is > or = X amount then the block will pass. So a drop down menu would change that value based on what pair I pick. XAUUSD has a desirable setting of ATR2-5, so I'd have it default to 3 when I click that on the drop down menu. XAGUSD(silver) has a desirable setting  of only ATR 0.05-0.2. Quite drastic. I can always change that setting manually with each pair I drop the EA on, but I just thought it would be nice and fancy if I coded a drop down menu with presets.

 
Nicholas #: Understandable. I just started coding. The last coding experience I had was creating CSS and HTML code in a web programming class over a decade ago! Thank you for your help, It's actually spot on I think. Just to verify we're both on the same page and that's what I need, what I'm trying to do is change the X parameter of ATR value is > or = X amount then the block will pass. So a drop down menu would change that value based on what pair I pick. XAUUSD has a desirable setting of ATR2-5, so I'd have it default to 3 when I click that on the drop down menu. XAGUSD(silver) has a desirable setting  of only ATR 0.05-0.2. Quite drastic. I can always change that setting manually with each pair I drop the EA on, but I just thought it would be nice and fancy if I coded a drop down menu with presets.

The principal is the same. Use the enumerator input to index into an array of ATR period settings, just like I indexed into an array of strings for the symbol names in my example above.

However, you will have to learn a lot more about how to code in MQL if you want to create your own EA.