Discussion of article "MQL5 Programming Basics: Global Variables of the Terminal" - page 2

 
Andrey F. Zelinsky:

The article expected clarification from the article:

1. -- how and where global variables are stored (in memory, on disc)

2. -- how often these global variables can be read

-- etc.

Unfortunately, I didn't find answers to the questions in the article.


1. There is a bit about this, in the section "GlobalVariablesFlush function".

2. Everything that is not forbidden is allowed.

 
Dmitry Fedoseev:

1. There is a bit about this, in the section "GlobalVariablesFlush function".

2. Anything that is not forbidden is allowed.

I'm interested in how variables are stored during operation -- memory/disk -- and how critical the frequency of variable writing/reading is for the disc.

what happens to a variable when the terminal is shut down abruptly.

in short, such questions -- it would be very useful to clarify them -- either in the article or here, in the discussion.

I remember something about this on the forum, but I can't find where, when and what.

 
Glob.variables are good, but you want a better one :-) I want an analogue, but in the chart namespace.
 
Andrey F. Zelinsky:

I am interested in how variables are stored during operation -- memory/disk -- and how critical the frequency of variable writing/reading is for the disc.

what happens to a variable when the terminal is abruptly shut down.

in short, such questions -- it would be very useful to clarify them -- either in the article or here, in the discussion.

I remember something was said on the forum about this -- but where, when and what -- I can't find it.

There is something here. The author is even testing something there...

Основы программирования на MQL5 - Глобальные переменные терминала
Основы программирования на MQL5 - Глобальные переменные терминала
  • 2014.11.03
  • //www.mql5.com/ru/users/denkir">
  • www.mql5.com
В данной статье демонстрируются объектно-ориентированные возможности языка MQL5 по созданию объектов, отвечающих за работу с глобальными переменными терминала. В качестве практического примера рассматривается ситуация, когда глобальные переменные могут использоваться как контрольные точки выполнения этапов программы.
 
Dennis Kirichenko:

There's something here. The author is even testing something there...

i don't get it -- two identical articles on the site?

both fedoseev's and yours -- and even the same title?

и


 
Andrey F. Zelinsky:

I am interested in how variables are stored during operation -- memory/disk -- and how critical the frequency of variable writing/reading is for the disc.

what happens to a variable when the terminal is abruptly shut down.

in short, such questions -- it would be very useful to clarify them -- either in the article or here, in the discussion.

I remember something about this on the forum, but I can't find where, when and what.

There is about it in the section "GlobalVariablesFlush function".

They are stored in a file. It will be reset to disc when the terminal is shut down or when GlobalVariablesFlush() is called.

There are different opinions about the service life of hard discs, there is even an opinion that the service life is more than 170 years. I wonder if you think about the same question when you listen to music or watch videos on your computer? Using global variables you can't achieve even a small part of the load on the disc that happens when playing music or video. And using the Internet, clicking on a link, do you know how many files are immediately saved to the disc? But using the Internet, no one thinks about the load on the disc.

Regular defragmentation significantly reduces the load on the disc. Also stable power supply (but for laptops there is no such problem), and temperature regime (but you can't do anything about it).

***

On the forum there was a discussion about GlobalVariablesFlush, terminal developers wrote that they disabled something there, but it was misunderstood. They disabled direct reset to disc. Previously, the reset was performed directly to the disc through the operating system. Now the reset is done through the operating system. Sort of makes it so that the reset can be done when the operating system decides to do it, rather than immediately upon a function call. An abrupt loss of power to a computer is an unrealistic phenomenon nowadays.

 
Maxim Kuznetsov:
Glob.variables are good, but you want a better one :-) I want an analogue, but in the chart namespace.
It can be solved through prefixes of global variables.
 
Andrey F. Zelinsky:

I don't get it -- two identical articles on the site?

Wow! What a miracle!
 
Andrey F. Zelinsky:

I don't get it -- two identical articles on the site?

Fedoseyev's and yours -- and even the same title?

Yeah, that's funny, first time I've seen that....

Dmitry, as always systematic and detailed. Respect

 
Maxim Kuznetsov:
Glob.variables are good, but you want a better one :-) You want an analogue, but in the chart namespace.

Well, then use it at the namespace level)

I have a slightly different implementation, but it's quite usable:

//===============================================================================================
//----------------------- Creates and returns the name of the global variable -----------------------+
//===============================================================================================
string GetGlobalVariableName(string name="", string symb="0") {
 if(symb=="0") { symb=_Symbol;}
  if(!IsTesting()) {
   return(prefix+symb+"_"+(string)AccountInfoInteger(ACCOUNT_LOGIN)+"_"+WindowExpertName()+"_"+name);
  } else {
   return(prefix+symb+"_"+(string)AccountInfoInteger(ACCOUNT_LOGIN)+"_"+WindowExpertName()+"_tester"+"_"+name);
 }}

It's just as easy to apply:

// here we write what we need with the name
if(если больше то) {
 GlobalVariableSet(GetGlobalVariableName("LastAmountPos"),с);
}
// here we get the same by name
int pos_count = GlobalVariableGet(GetGlobalVariableName("LastAmountPos"));

You can end up with a value anywhere at the name level of"pos_count".

In general, there are no restrictions with the application, very simple, fast and convenient, for which the MC thanks a lot!