why I cant set values of custom enum inputs of an indicator with iCustom?

 

Well, I have a indicator with a enum input:


#property script_show_inputs
enum metodo
  {
   MA,     // MA
   vwap,     // VWAP
  };
input metodo mtd=MA; //Método de cálculo


Looking for can change the method with a input in the EA, I created the same enum input in EA and this have no effects: 


#property script_show_inputs
enum metodo
  {
   MA,     // MA
   vwap,     // VWAP
  };
input metodo mtd=MA; //Método de cálculo


And I call this indicator with iCustom (the other inputs are ok, I tested all):


handle = iCustom(_Symbol,...,mtd);


Im thinking about this last week and cant solve this. Should I declare any type of input or some thing like this?

The modification of the input "mtd" have no effect to the indicator. He shows only default value (MA).

Pls help

 

I have solved the problem during last hours thinking about. If you have the same problem, the solution is on iCustom, instead "mtd" I used "metodo (mtd)":


handle = iCustom(_Symbol,...,metodo(mtd));
 
Lucas Jose Munoz Dentello #: the solution is on iCustom, instead "mtd" I used "metodo (mtd)":

This is not a solution. Mtd is a metodo; you are casting an X to an X which does nothing. Your problem was elsewhere.

 
William Roeder #:

This is not a solution. Mtd is a metodo; you are casting an X to an X which does nothing. Your problem was elsewhere.

Hello will thanks for comment.


Can you show me where is the real problem?


By this way I showed I can modify the indicator input through EA input and this works 100%.

 
Try this in indicator
#property indicator_separate_window
#property indicator_buffers 1
#property indicator_color1 Blue

enum metodo
{
   MA,     // MA
   vwap,     // VWAP
};

input metodo mtd=MA; // Método de cálculo

//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit()
  {
   // Indicator buffers and lines
   SetIndexBuffer(0, ExtMapBuffer1);
   SetIndexStyle(0, DRAW_LINE);
   SetIndexLabel(0, "Custom Indicator");

   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int OnCalculate(const int rates_total,
                const int prev_calculated,
                const datetime &time[],
                const double &open[],
                const double &high[],
                const double &low[],
                const double &close[],
                const long &tick_volume[],
                const long &volume[],
                const int &spread[])
  {
   // Calculation logic based on mtd variable
   // You can access mtd using the variable name 'mtd'
   // For example:
   // if (mtd == MA) { // Calculate based on Moving Average }
   // else if (mtd == vwap) { // Calculate based on VWAP }
   return(rates_total);
  }

Then this in EA
enum metodo
{
   MA,     // MA
   vwap,     // VWAP
};

input metodo mtd=MA; // Método de cálculo

// Example of using iCustom to call the indicator
double handle = iCustom(_Symbol, PERIOD_CURRENT, "YourIndicatorName", mtd);

Ensure that

  •   "YourIndicatorName" in the iCustom function matches the name of your custom indicator file exactly;
  •  the enum metodo definition is identical in both the indicator and the EA.

Will be fine!