SDC:
I ran into this a long time ago. Then I read it's bad practice to make a global variable and local variable the same name. Some naming convention is starting global variables with _underscore and others is with Capitalization while local variables starts with non-caps. Some editors would flag this problem but meta-editor4 doesn't. Anyways, once you know which one takes priority, it makes it easier to ketch this error in the future 8P.
Just a snippet of information that I have not seen written into the documentation it might be useful to someone when debugging. I accidentally declared a variable both globalscope and localy it works in the following way.
If a variable is declared globalscope and a variable of the same name is declared locally, the local variable takes precedence in it's function and changes to the value of that variable in it's function, only affects the local version of that variable, the global version remains unchanged. This was the cause of a bug that took me all day to find :(
Yes what i did was bad practice, I dont think I'll be making that mistake again lol
You don't make that error with a naming convention. Ubzen suggested underscore/capitalization. I use noDots=local, dotted.variable=global, Capitalized.Variable=external global. Just be consistent.
![MQL5 - Language of trade strategies built-in the MetaTrader 5 client terminal](https://c.mql5.com/i/registerlandings/logo-2.png)
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
Just a snippet of information that I have not seen written into the documentation it might be useful to someone when debugging. I accidentally declared a variable both globalscope and localy it works in the following way.
If a variable is declared globalscope and a variable of the same name is declared locally, the local variable takes precedence in it's function and changes to the value of that variable in it's function, only affects the local version of that variable, the global version remains unchanged. This was the cause of a bug that took me all day to find :(