No, the MQL language is not interpreted at run-time. It is compiled, so you cannot have "variable" variable names. You will have to use other alternatives, such as Key-Value Collections (implemented as classes or even as arrays) to achieve similar constructs. To do that, you will have to some research into the subject, as well as learn other general coding practices for compiled coding languages.
mzc82: I would like to print the value of the variable depending on the string passed to the function check.
-
Play videoPlease edit your post.
For large amounts of code, attach it. - Do exactly what you said.
void check( string valute){ if( valute == "EURUSD") Print(highprecEURUSD); else if(valute == "USDEUR") Print(highprecUSDEUR); else Print("UNVALID"); }
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Hi,
I variables with the name that is variable.
I try to explain:
double highprecEURUSD = 0;
double highprecUSDEUR = 0;
check ("EURUSD");
void check( string valute){
Print(highprec + valute);
}
I would like to print the value of the variable depending on the string passed to the function check.
Help me.
Thanks
Marco