It behaves as global variable, except that it can be accessed only inside this loop. but 0 will be assigned to it only once.
Documentation on MQL5: Language Basics / Variables / Static Variables
- www.mql5.com
Static Variables - Variables - Language Basics - MQL5 Reference - Reference on algorithmic/automated trading language for MetaTrader 5
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
Hey guys,
I am away from my personal computer for a few days, so I can't test it myself, and I couldn't find an answer online,
But suddenly it occurred to me that perhaps I have a logical bug in a code I've written.
My question is-
How does a static variable 'behaves' inside a loop?
Consider the following example (this piece of code is just to illustrate my question)-
Would the static iCount variable will act as sort-of a global variable, which means that all iterations of the loop will access the same instance/value,
Or does each iteration will have its own individual instance of iCount?
I am not an native English speaker,
So I hope I've phrased my question clear enough.
Any input will be appreciated guys.
Thanks.