Questions from Beginners MQL5 MT5 MetaTrader 5 - page 682

 
Artyom Trishkin:

I'm talking about Thomas, he's talking about Yeroma...

How do you communicate in this situation?

I am speaking about a pernicious habit of thoughtlessly initializing global variables in OnInit().

At the same time you impose your detrimental habit to all newcomers in an unquestioning form. You're creating a generation of E.S.E.'s? Clones of those who don't think, but blindly follow their sensei?

"Mindlessly initializeglobal variables" are your words and your fiction. If you do it thoughtlessly, there is only one piece of advice: "The money is yours, do what you want".
 
Vladimir Karputov:
"Mindlessly initialiseglobal variables" - those are your words and your fiction. If you do it thoughtlessly, there is only one piece of advice: "The money is yours, do what you want".

No. Those are YOUR words. And your 'teaching' to the questioner:


This is not the way to do it:

bool TimeFlag,FLG;
int TimeScale=50,TimeInMemory,TimeNow;

or rather after such a declaration, you must explicitly initialize(assign values to) these variables in OnInit().

The Sell method must also be surrounded by checks, such as

trade.ResultRetcode(),
" (",trade.ResultRetcodeDescription(),"));

And there may be one catch - in the morning, at the opening of trading, trading is not immediately, not from the first second - that's when errors are possible.


And then he, following your, to put it mildly, thoughtless advice, will think - why has he lost his money ...

YOU are the one saying that after declaring a variable without explicitly initializing it, you must initialize it explicitly in OnInit() .

The result of this thoughtless action, you could have seen when running the attached test EA - the loss of the variable value when the timeframe changes.

ZS. Have the courage to admit your mistakes and shortcomings.

ZZZY. So my words about mindlessness of your suggested blind mandatory initialization in OnInit() - correspond to my assertion that you suggest mindlessly stupidly initialize global variables in OnInit()

 

tell me in which build

ACCOUNT_FREEMARGIN

changed to

ACCOUNT_MARGIN_FREE

 
Artyom Trishkin:


Please continue to live in your imaginary world and look for what is not there.
 
Vladimir Karputov:
Please continue to live in your imaginary world and look for something that isn't there.

You have a test EA in front of you. The way you teach beginners to initialise global variables will cause them to lose their values when you switch timeframes. You need to be aware of this and not do it in a mindless way. But if you initialise global variables NOT as you suggest, then their values are not lost when you change timeframe - consequently there is no violation of logic in some cases where the value of a global variable should not depend on a timeframe change.

So the world is imaginary - you have it. It's you, who lives in a world of your own, thinking that you are surrounded by checks and initializations (thoughtless), and everything is OK.

But the checking advisor proves that it is in your case that the person can lose his money. In my case, on the other hand, he can easily switch the timeframe of the chart on which his EA is running.

Experience does not come from reading the reference. Think more often, think of different situations.

ZS. Instead of saying "thank you" saying "I didn't know, I will take it into account, thank you", you start to put on a show of childishness and insults ...

Wouldn't be surprised if you get banned - if you want to get to know a person, give him some power.

 
Artyom Trishkin:

You have a test EA in front of you. The way you teach beginners to initialise global variables will cause them to lose their values when you switch timeframes. You need to be aware of this, and not do it in a mindless way. But if you initialise global variables NOT as you suggest, then their values are not lost when you change timeframe - consequently there is no violation of logic in some cases where the value of a global variable should not depend on a timeframe change.

So the world is imaginary - you have it. It's you, who lives in a world of your own, thinking that you are surrounded by checks and initializations (thoughtless), and everything is OK.

But the checking advisor proves that it is in your case that the person can lose his money. In my case, on the other hand, he can easily switch the timeframe of the chart on which his EA is running.

Experience does not come from reading the reference. Think more often, think of different situations.

ZS. Instead of saying "thank you" saying "I didn't know, I will take it into account, thank you", you start to put on a show of childishness and insults ...

Wouldn't be surprised if you get banned - if you want to get to know a person, give him some power.

Spit it out, don't get upset. The more of this nonsense he will write the less will stay on this forum newbies and more will leave experienced, and therefore the administration will think about why this is happening.

And where is it written that there will always be a problem if the variable is left uninitialized? Everywhere it says only possible error, ONLY possible... This is a consequence of ege, from the first generation.

 
Alexey Viktorov:

Don't get upset, don't get upset. The more nonsense he writes, the fewer newbies will stay on this forum and the more experienced ones will leave, and the administration will wonder why this is happening.

And where is it written that there will always be a problem if the variable is left uninitialized? Everywhere it says only about a possible error, ONLY possible... This is a consequence of ege, from the first generation.

I'm not upset - I've reported incorrect statements. That man, misled, understood that he was misled, and that does not need to stupidly engage in copy-paste someone else's conclusions, and he thought, and understood that will happen in this or that case. The case has even shown with a simple test EA. So, on the contrary, I am calm: forewarned is forearmed.

But you still should initialize variables, IMHO, not relying too much on default implicit initialization values, but thinking and understanding where, how and with what value, rather than the way "said on the forum MODERATOR is the absolute truth"... A moderator is not a developer.

 
Artyom Trishkin:

I'm not upset - I've reported incorrect statements. So that the misled person understands that they are misled and that they don't have to stupidly copy-paste someone else's conclusions, but think for themselves and understand what will happen in this or that case. The case has even shown with a simple test EA. So, on the contrary, I am calm: forewarned is forearmed.

But to initialize variables, IMHO, all the same, it is necessary, not especially relying on default values of implicit initialization, but thinking and understanding where, how, and by what value, but not as "said on a forum MODERATOR - it means the truth in the last instance"... A moderator is not a developer.

By the way, the question you raised, it would be useful to make a separate thread in general - if Renat creates FAC forum, and Karputov is hanging out/dropping/sharing threads according to some criteria of his own.

Not everyone really knows how global variables are initialized - even the "main hint" Karputov is "floating".

And last time on 4, I remember that the topic was raised back in 2011.

p.s. If you could create this thread, Artem -- think of a title, saying - you have a test program there - let the search engine find the question.

 
Andrey F. Zelinsky:

By the way, the question you raised is useful to make a separate thread in general -- if Renat creates FAC forum, and Karputov hangs/shreds/joins threads according to some criteria of his own.

Not everyone really knows how global variables are initialized - even the "main hint" Karputov is "floating".

And last time on 4, I remember that the topic was raised back in 2011.

p.s. You should create yourself this thread, Artem -- think of a name telling -- you have a test program there -- let the search engine find the question.

No problem. I did. I hope it will be possible to share other knowledge and methods there.
 
Comments not relevant to this topic have been moved to "Hint, it's starting to get laggy)".
Reason: