Download MetaTrader 5

Can we get variable with variable name?

To add comments, please log in or register
selnomeria
254
selnomeria  

Is it possible to get variables like this?:


double NewStopLevel =  GetVariable("OldStopLevel") + 12;    //because "OldStopLevel is outside of this indicator, and I'm trying to build a way to call that.


i.e. something like this?

string GetVariable(string variable_name){

return $variable_name;

}

honest_knave
Moderator
2342
honest_knave  

If you want to share variables between different indicators and EAs within the same terminal, use Global Variables of the Terminal (or read/write them to file).

Global Variables of the Terminal - MQL4 Reference
Global Variables of the Terminal - MQL4 Reference
  • docs.mql4.com
Global Variables of the Terminal - MQL4 Reference
selnomeria
254
selnomeria  
honest_knave:

If you want to share variables between different indicators and EAs within the same terminal, use Global Variables of the Terminal (or read/write them to file).

1) GlobalVariables seems somehow better to me, but not solution (but i should have specific variable names for each indicator session, not to mix with each other... )

for  example, i have global condition, named "IsBuySignalBar" , then this condition will be read from all indicators, however, this condition is formed only with specific parameters, for different sybmols.



2) about "read/write" method:  I have tens of variables, which are executed on every bar and read/write is not a preferred  way, however, is there is no other way, ok.    For ticks, it wont be good solution.

To add comments, please log in or register