[WARNING CLOSED!] Any newbie question, so as not to clutter up the forum. Professionals, don't go by. Can't go anywhere without you. - page 721

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
The point is not to multiply variables, many conditions and counters.
the point is to write correctly then, not to use language abbreviations:
The point is not to create variables, lots of conditions and counters.
So please, the compiler allows you to do such things...
The default flag is False, so the first for loop in which the variable a is declared will not be executed, which does not prevent the same "undeclared" variable from being used in the else branch : )The condition if
here we do something
otherwise if another condition
do something else
The point is not to create variables, lots of conditions and counters.
so the first for loop in which the variable a is declared will not be executed
the point of writing correctly then, rather than using abbreviations of language:
This does not require you to re-initialise the variable. Do everything according to what you have written and your variable a will be used in the right places in your logical branches without re-initialisation. Declare it once and use it for your benefit and the benefit of mankind... :) The main thing is not to get lost where and what you use it for...
The "effect" shown above proves that MQL-machine first looks through EX4 file for declared variables, and creates them regardless of logical branches in full. On the one hand it turns out not to save RAM, and on the other hand you can create similar constructions, although in my opinion this style is not the best option.
The whole problem was in the lack of {}, wasn't it? Thanks a lot!
The whole problem was in the declaration of the variable:
int a;
I declare it and then use it where and when needed, while you had a repeated declaration of a variable - most likely the compiler didn't skip it
If you have only one statement in the loop then you don't need {}, but if you have more then you have to put {}, otherwise you will look for why the loop isn't calculated correctly
SZZY: If you have just started, put curly brackets after for, you will get the hang of it later
The loop must always be executed.
What does the loop have to do with it? It's just an example that a variable created in a block which is not used is still in "play" and will be visible and usable throughout the start() method, without the need to re-initialize it, much less de-initialize it before reuse.