Features of the mql5 language, subtleties and tricks - page 248
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
How about this?
Insert your variant here and compare.
Astatic variable declared inside a method of a class is a static variable of the class itself.
result
1
2
3
Not that special. I checked, it's the same in C++. And it seems to make sense. But I didn't know it personally. That's why by habit I often used static variables in class methods, making hard-to-see mistakes (when there are several class objects).
I use it for speed, so that I don't have to allocate memory on each call. I haven't measured it, though. Probably self-delusion.
I think it's justified. But, yes, it would be interesting to measure it. Maybe accessing a global variable takes longer than allocating new memory.
I think it's justified. But, yes, it would be interesting to measure it. Maybe access to a global variable takes longer than new memory allocation.
It will depend on many factors.
Hence the conclusion: don't use static instead of local storage in the above context, it won't be better, but it will almost certainly be worse.
PS. If you remove static in that example, you should also remove the initialisation of the structure, so as not to waste CPU time, it will be initialised in SymbolInfoTick.
It's going to depend on a lot of factors.
Hence the conclusion: don't use static instead of local storage in the above context, it won't be better, but it will almost certainly be worse.
PS. If you remove static in that example, you should also remove the initialisation of the structure, so as not to waste CPU time, it will be initialised in SymbolInfoTick.
I quite admit it.
It will depend on many factors.
Hence the conclusion: don't use static instead of local storage in the above context, it won't be better, but it will almost certainly be worse.
PS. If you remove static in that example, you should also remove the initialisation of the structure, so as not to waste CPU time, it will be initialised in SymbolInfoTick.
I tried it.
Result.
Frankly speaking, I don't understand why the second line gets zero when there is no initialisation.
I tried it.
Result.
Frankly speaking, I don't understand why the second line gets zero when there is no initialisation.