Different Indicators Parameters to iCustom

Hello
I’m trying to make an ea where the user can type the name of the indicator in the ea settings and type list of comma separated parameters.

next i want to detect the type of every parameter and then pass it to the iCustom.

and to check if this parameter is string or double i tell the user if it string leave it as default

the default parameter is 5555

so here is the check

if(parameter1==5555){ string par1="string1"; } else{double par1=parameter1;}

and so on for the next parameters then at the end of the check and declaration of parameters i call the indicator

iCustom(_Symbol,_Period,indicator_name,par1,par2,par3,par4,indicator_buffer,1);

the problem is that the defined variables are only accessed in the if statement scope
tried to create a function inside it and return the value and use function overloading but didn’t work as it’s not allowed to create function inside a function.
so i need any way to make the local variables accessed in the ontick scope.
Please help.

@Mad_Gamer This is not a scoping issue. Your variables are defined outside the if statement and should are accessible in iCustom. If you need more help post your code so we can have a look

input double parameter1=5555;
input double parameter2=5555;
input double parameter3=5555;
input double parameter4=5555;

this code is in the global scope above the OnInit function

if(parameter1==5555)
{
string par1="string1";
}
else
{
double par1=parameter1;
}
//
if(parameter2==5555)
{
string par2="string2";
}
else
{
double par2=parameter2;
}

and so on
this is inside ontick function and after this comes the icustom function outside the if scope
iCustom(_Symbol,_Period,indicator_name,par1,par2,par3,par4,indicator_buffer,1);

so any suggestions?

actually looking at your code again, it does look like a scoping issue. What error are you getting? Also, consider having two variables instead of one. Also you should be defining your variables outside the if blocks

string par1string = "";
double par1double = 0;

if(parameter1==5555)
{
   par1string="string1";
} else {
    par1double=parameter1;
}

// then see which one has been assigned a value and use that
if( par1string != "" )
{
   // do something with par1string
} else {
  // do something with par1double
}

Hope that helps

the problem is i want to call icustom and when there is like 20 inputs and 3 of them are strings and the rest is double there would be a lot of probabilities for the parameters order.

Was there a final solution? I am looking to try and do the same. :frowning:

Can you post your full solution?

1 Like