The only ways to get some "directory" of names and indices of globalvars is to call
string GlobalVariableName(int index)
and check the names that it is returning until it fits.
The other thing is if one calls
int GlobalVariablesTotal()
before every creation of a global variable and save the new index with the new name somewhere. So to have a full directory of all current global variables one could as well create the whole catalogue to begin with.
It feels kind of arbitrary when multiple programs produce these arrays simultaneously...?
When dealing with the problem of returning an index the best solution seems to create names which begin with gvar followed by a separator and the index number...
BUT: since the terminal already has knowledge of their names and indizes, wouldn't it be practical to have a function
int GlobalVariableIndex(string name) ?
- Enumerate global variables?
- Problem when working with Array....
- Getting a list of global variables
Maybe I'm missing something in your question, but why would you want to know the index of a Global Terminal Variable if you already have it's name?
If you have its name then you can get or set it. There is no need to know its index (which can change at any moment at given moment).
Can you give a more concrete example of why you would want to find the index for a given name?
BUT: since the terminal already has knowledge of their names and indizes, wouldn't it be practical to have a function
What prevents you from writing this function yourself?
Fernando Carreiro #:
You are right and that is the ultimate argument against it. I got so wound up in thinking how to make the class maximally practical that I overlooked this simple fact.If you have its name then you can get or set it. There is no need to know its index (which can change at any moment at given moment).
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