Any questions from newcomers on MQL4 and MQL5, help and discussion on algorithms and codes - page 1063
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
Execution cannot be pardoned.
What is the error?
Here.
As you can see, you cannot pass a locally declared structure to a function.
Can you please tell me if there is a way to change opening times of bars h4 and d1? Roughly speaking imitate a change of timezone. Maybe a script that builds offline charts based on h1 timeframe or something like that.
We need to work with this
Here.
As you can see, you cannot pass a locally declared structure to a function.
Can you check it yourself? Difficult? And why write too much?
I haven't checked. What's stopping you?
Artyom, this option really won't work. The structure has to be defined at the global variable level. And a variable of structure type is anywhere. Then it will be possible to pass it by reference. Because the type in incoming function parameters will not be defined.
You confuse definition of a structure with declaration of a variable with the type of this structure.
Meaning. You mean that the structure must be declared globally, i.e. outside the code, and the structure by its definition cannot be described inside the code, i.e. locally; only variables can be created this way, or am I misunderstanding something? Please explain.
Artyom, this variant really won't work. The structure should be defined at the level of global variables. And a variable of structure type is anywhere. Then it will be possible to transfer it by reference. Because the type in incoming parameters of function will not be defined.
So it's global after all.
So it's global after all.
NO. A structure is a user-defined type. So this type must be available everywhere. And a VARIABLE of a custom type can be declared wherever the left pinky of the right foot wants and pass this variable wherever the beloved dog wants, but only by reference.
This way the structure will not work, Artyom. The structure must be defined at the level of global variables. And the variable of structure type is anywhere. Then it will be possible to transfer it by reference. Because the type in incoming function parameters will not be defined.
Forum on trading, automated trading systems & strategy testing
Any questions from newbies on MQL4 and MQL5, help and discussion on algorithms and codes
declaring a variable with the type of that structure.
In general, since Artyom does not answer anything, and the man above gave the answer that functions work with structures that must be known and therefore must be declared globally, we conclude that the structure must be declared globally.
By its nature, a function that works with a structure can only accept the same static structures. It means that it is impossible to declare a structure locally so that it has a limited scope and pass it to the function.