Operator: ?: https://www.mql5.com/en/docs/basis/operators
cadena = (A<3) ? "A==B && RSI>30" : "A<=B && RSI>30";
But what do you expect with if(cadena)?
Does this meat your ideas(?):
double A=2.5, B=4; bool cadena; cadena = (A<3) ? A==B && RSI>30 : A<=B && RSI>30; if(cadena) { ....... }

- www.mql5.com
For example, in this case, is there any way to do it?
cadena is a "string" type, not a "bool" type ... if operator needs a "bool" expression, an expression that can take a true or false value, in parantheses to be able to make a choice,
You can use string variables in if expressions in the following way.
if (cadena == "123") { ... }
bool RSI, MA, MOM; double mRSI, mMA, mMOM; string cadena; if(RSI==true){ if(MA=true){ if(MOM==true) cadena=".... && mRSI>30 && mMA>60 && mMOM>60); else cadena=".... && mRSI>30 && mMA>60); } else { if(MOM==true) cadena=".... && mRSI>30 && mMOM>60); else cadena=".... && mRSI>30); } } else { if(MA=true){ if(MOM==true) cadena=".... && mMA>60 && mMOM>60); else cadena=".... && mRSI>30 && mMA>60); } else { if(MOM==true) cadena=".... && mMOM>60); else cadena=".... ); } } if(cadena) { ....... }I intended to predefine a pre-selectable conditional package (with several selectable alternative Boolean variables), to run a single conditional analysis.
Did I make myself clear? Just in case this example:
input bool useRSI=true; input bool useMOM=false; ⋮ double mRsi = …; ⋮ bool condition1 = !useRSI || mRsi > 30; bool condition2 = … bool result = condition1 && condition2 …;
You would never write if( (2+2 == 4) == true) would you? if(2+2 == 4) is sufficient. So don't write if(bool == true), just use if(bool) or if(!bool). Code becomes self documenting when you use meaningful variable names, like bool isLongEnabled where as Long_Entry sounds like a trigger price or a ticket number and “if long entry” is an incomplete sentence.
For example, in this case, is there any way to do it?
Why do you want to make it a string ? Just make it a bool :
double A=2.5, B=4; bool cadena=false; if(A<3) cadena=A==B && RSI>30; else cadena=A<=B && RSI>30; if(cadena) { ....... }
Nunca escribirías if( (2+2 == 4) == true) ¿ o sí? si (2+2 == 4) es suficiente. Así que no escribas if(bool == true) , solo usa if(bool) o if( ! bool) . El código se vuelve autodocumentado cuando usa nombres de variables significativas, como bool isLongEnabled , donde Long_Entry suena como un precio de activación o un número de boleto y "if long entry" es una oración incomple
Understood, that's what being self-taught is all about. thank you.

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
For example, in this case, is there any way to do it?