
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
Because it doesn't provide for the variable to be initialised on program restart, it MUST.
Once again, for those in the tank:
Example works. Initialisation works.Although this point(from the textbook) is not quite clear to me:
"Static variables are initialized once before calling the specialized init() function, i.e., the value of this variable is not lost when leaving the function, within which a static variable is declared.
What does this have to do with, " before calling the special init() function " and after " i.e. when you exit a user function (judging by the content) in which a static variable is declared? "
A function in which a static variable is declared can be at the end of a program... i.e. at the end of code or somewhere else. Theinit() function is executed once just before the program starts. It turns out to be inconsistent. How can a variable be initialized before theinit() function?
It doesn't matter where the function is in the program, the variables static are outside the functions.
What do you mean?
No, it won't. It's a bug :)
What do you mean?
Static variables are stored in a permanent area of program memory, their values are not lost when the function is exited.
Once again, for those in the tank:
The example works. The initialisation works.Clinic...
Yes, initialisation works. Exactly once. And on restart, it doesn't. I wish it did. Is that clearer?
Clinic...
Yes, the initialisation works. Exactly once. And on restart, it doesn't. I wish it did. Is that clearer?
It shall work only once, when you restart the Expert Advisor.
What do you mean by restart, entering the Expert Advisor properties and exiting by pressing OK?
For fuck's sake, don't use statics in EAs.
Yes, and also:
1. When the account is changed;
2. When changing an instrument;
3. When changing the TF.