get a global variable, save the global variable, so what? I'm sorry, dear, but I don't understand anything. Why do you even need these variables?
I apologise. This example was created in response to a request of one of the forum members: we needed an example of working with global variables of the terminal. Global variables of the terminal save their values after reloading the terminal and this example shows how to read and write a global variable.
Thanks, useful code! But it didn't work for MT4... Can you please advise me how to better adapt this sample code for MT4?
Thanks, useful code! But it didn't work for MT4... Would you mind giving advice on how to better adapt this sample code for MT4?
Not a clear example... Never got a chance to apply it.... And how to save two variables (two price levels) is not clear...?
Show me what didn't work, please.
Not clear example... I never managed to apply it.... And how to save two variables (two price levels) is not clear...?
And in what place of the programme do you want to save values: in OnInit(), in OnTick() or in OnDeinit?
Show me what didn't work, please.
And in what place of the programme do you want to save values: in OnInit(), in OnTick() or in OnDeinit?
I save values in OnTick(), and tried to get them with OnInit(), but it didn't work. It worked only in this way: I saved in OnTick() - GlobalVariableSet("OER", OER ); and here, in OnTick(), the very first condition - if orders are more than 0, then OER = GlobalVariableGet("OER"). Now the OER variable is not reset on reloading. Do you think this is the right way to write the code?
What is the purpose of saving prices in global variables? What do you want to implement? What is the algorithm of action?
When reloading, two variables are reset to zero and because of this the EA does not work correctly when loading. I need to learn how to save these variables for such a case (if there are orders when loading, use data from glob.).
In OnDeinit() write your condition - whether or not you need to overwrite your global variables.
In general, I ask again: "What is the algorithm of action?". At the moment it's a heap-mala. Understand that unless you understand what you need, you will not be able to implement it. Draw a flowchart - it will help.
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
GlobalVariable:
Author: Karputov Vladimir