- iCustom - Load parameters from input dynamically (including bool parameters)
- MQL4 calling a custom indicator into an EA that has 100+ input parameters
- Errors, bugs, questions
@ Miguel Antonio Rojas Martinez
You can simply do it in 3 ways.
void OnTick() { //--- Str // 1. string a[10]={"0.7","650"}; double expectedCode =iCustom(Symbol(),0,"NAMEINDICATOR",a[0],a[1],0,0); Print(a[0]," X ",a[1]); // 2. string b="0.7,650"; string sep=","; // A separator as a character ushort u_sep; // The code of the separator character string b1[]; // An array to get strings u_sep=StringGetCharacter(sep,0); int k=StringSplit(b,u_sep,b1); Print(b1[0]," X ",b1[1]); double expectedCodeb; //3. switch(ArraySize(b1)) { //Close opened long positions case 1 : expectedCodeb =iCustom(Symbol(),0,"NAMEINDICATOR",b1[0],0,0); break; case 2 : expectedCodeb =iCustom(Symbol(),0,"NAMEINDICATOR",b1[0],b1[1],0,0); break; case 3 : expectedCodeb =iCustom(Symbol(),0,"NAMEINDICATOR",b1[0],b1[1],b1[2],0,0); break; case 4 : expectedCodeb =iCustom(Symbol(),0,"NAMEINDICATOR",b1[0],b1[1],b1[1],b1[2],b1[3],0,0); break; } } //+------------------------------------------------------------------+

- 2019.11.19
- www.mql5.com
There are no variadic functions.
See the following:
Define Variadic Arguments in Functions? - Bollinger Bands, BB - Expert Advisors and Automated Trading - MQL5 programming forum 2018.04.19
Function with variable number of parameters - MQL4 programming forum 2018.01.06
Different Indicators Parameters to iCustom - MQL5 programming forum 2020.04.27
So the ternary operator, at that point, always returns a string in that "input" of the icustom
iCustom(Symbol(),0,NameIndicator,( ISNUMBER (array[0]))?(double)array[0]:array[0],(ISNUMBER MERO(array[1]))?(double)array[1]:array[1],Buffer, 0);
I also tried with this, templates and a class, but it doesn't help me, because I have to declare the class variable with a type, and then, the same, I don't advance.
template<typename T> T val (T val1) { return val1; } //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ class INPUT { public: xxxxx ret; // Here the problem, because i need declare a type. public: INPUT(string valor); }; //------------------------------------------------------------+ INPUT::INPUT(string valor) { if(ISNUMBER(valor)) { ret = val( StringToDouble(valor)); } else { ret = val(string(valor)); } } //+------------------------------------------------------------------+
Thanks for if you can give me a hand
What part of “There are no variadic functions.” was unclear?

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use