A bug in the OrderSend() function ? - page 6

 
tara:

What's Static then? It's more like Fatalic...
Why doesn't static work? It works everywhere. Fatalic, naphthalic, no way! I'm always looking for faults in myself and getting offended!
 
borilunad:
Why doesn't static work? It works everywhere I go. Fatalik, naphthalik, it can't be! I'm always looking for errors in myself and getting offended!
Because it doesn't provide for variable initialization at program restart, it MUST.
 
By the way, all static data in MQL4 has the same disease. Reminder: all arrays are static:)
 
tara:
Because it does not provide for variable initialization at program restart, it MUST.
Right, as in any function, even a local one, static is first presented with some value, then it is compared. Although at first I used it without any idea, checking it in action, and then comes the understanding. It's impossible to understand everything at once, and not everything can be arranged so easily at once. :) I don't touch arrays, they're too much work for me!
 
granit77:
Are there any other programmers who can confirm this? One vote would not be enough.
Victor, I'm not a programmer, unfortunately. I'm an amateur...
 
tara:

You can simply change some parameter. The reaction will occur only after the first tick of a new bar on the set TF.

But you yourself have wondered why the EA's operation is unexplainable on higher TF:)



I wonder if there is connection between the first tick of a new bar and the tester... I don't see it. A tester is a tester. And a chart... is a chart... (I don't mean a tester, but the same demo or real).

Besides, the textbook says... "If there is no explicit initialization, then a static variable is initialized by zero".

So there's no need, as you said, Alexey, in INIT to assign value 0 to lastBarTime variable. It will be zero when the program starts.

 
hoz:


I wonder if there is connection between the first tick of a new bar in the working TF and the tester... ...well, I don't notice it... A tester is a tester. And a chart... is a chart... (I don't mean the tester, but the same demo or real).

In addition, the textbook says. "If there is no explicit initialization, a static variable is initialized by zero".

So there is no need, as you said, Alexey, to assign value 0 to lastBarTime variable in INIT. It will be zero when the program starts.


No, it won't. It's a bug :)
 

Although this point(from the textbook) is not quite clear to me:

" Static variables are initialized once before calling the specialized init() function, i.e., the value of this variable is not lost on exit from the function, within which a static variable is declared.

What does this have to do with, " before calling the special init() function " and after " i.e. when you exit a user function (judging by the content) in which a static variable is declared? "

A function in which a static variable is declared can be at the end of a program... i.e. at the end of code or somewhere else. Theinit() function is executed once just before the program starts. It turns out to be inconsistent. How can a variable be initialized before theinit() function?

 
hoz:

Although this point(from the textbook) is not quite clear to me:

"Static variables are initialized once before calling the specialized init() function, i.e., the value of this variable is not lost on exit from the function, within which a static variable is declared.

What does this have to do with, " before calling the special init() function " and after " i.e. when you exit a user function (judging by the content) in which a static variable is declared? "

A function in which a static variable is declared can be at the end of a program... i.e. at the end of code or somewhere else. Theinit() function is executed once just before the program starts. It turns out to be inconsistent. How can a variable be initialized before theinit() function?

Well, if you are interested - all currently used modes of memory management were first implemented in PL/1. There are four of them: Automatic, Dynamic, Static and Based. C came after and fully adopted these standards.

 
I'm going to bed now:)
Reason: