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
An example would be...
Like this (not the structure, but the class, of course):
What to put where, I think, is clear.
Don't forget at the end:
Let me rephrase. You're wondering if it's possible, when defining a function
specify only a variable of the structure type as its formal parameter, ignoring the name of the structure itself? I.e. specify, for example, not void funcName(MqlTradeRequest & req), but just void funcName(& req)?
Yes. You need a universal function for any simple structure --- No methods, din. arrays. etc. --- purely a sequence of specific data types.
Since the composition of the script is predetermined by me, I can explicitly specify the number of structures to deal with.
But to pass any of these structures intofunction with one name, I have to use overloading.
There are some difficulties here.
1. The number of structures is limited, because overloading will slow down if you have more elements.
2. I myself may make a mistake when copying the overloading functions.
PS// ThefunWrite() function performs certain calculations and executesFileWriteArray() with a certain sequence and calculated parameters (which index to write from, how many to read).
Yes. You need a universal function for any simple structure --- No methods, din. arrays. etc. --- purely a sequence of specific data types.
Since the composition of the script is pre-defined by me, I can explicitly specify the number of structures to deal with.
But to pass any of these structures to a function with one name, I have to use overloading.
I see. Some time ago I asked a similar question about whether it was possible not to specify the type of arrays when defining a function. Just below there, Roche advised overloading.
So I came to the conclusion that "built-in" functions likeFileWriteArray(), whichhave some parameters specified with void type, are themselves overloaded functions. We just do not see their implementation.
I see. I asked a similar question once before about whether it was possible not to specify the type of arrays when defining a function. Just below there, Roche advised overloading.
So I came to the conclusion that "built-in" functions likeFileWriteArray(), whichhave some parameters specified with void type, are themselves overloaded functions. We just cannot see their implementation.
Built-in functions are written in a full programming language.
In C, for example, you can pass any number of variables, and already in the function get a list of passed parameters and examine them.
void fun(...) { }
In MQL5, there is no such a possibility. In particular, links and pointers to simple data types and structures are missing...
It must have something to do with security. Access to data. Going outside the sandbox.
But I still wish these features were implemented in MQL5
It must have something to do with security. Access to data. Going outside the sandbox.
But I still want these features to be implemented in MQL5
Like this (not the structure, but the class, of course):
I think it's clear what to put in where.
At the end, don't forget:
Now that's what I call help: real and quite concrete. Thank you. Where's the plus sign?
By the way... I've been figuring that's good enough for me. But I don't want to be a formalist... ... so out of curiosity I decided that it wouldn't hurt to try organizing a two-dimensional array. MQL reminds me something of C/C++, which I have forgotten over the past dozen or so years. Now I've tried to do it this way (without loop - I intentionally simplified it):
The compiler generates the error: "'MABuffer' - parameter conversion is not allowed".
I wonder what I'm doing wrong. If I'm not mistaken, when declaring a class with multidimensional array it's necessary to specify numerically one of measurements, making it static?ArrayResize, meanwhile, setsnew size for the first dimension.
x100intraday:
I wonder what I'm doing wrong?
1) SetIndexBuffer works with an array of doubles of the same dimension.
2) It's not clear why you're using TBuffer*, i.e. using dynamics where it's not needed?
3) (TIP) In the example, you could have done with a structure rather than a class, to save a little memory and a couple of hundred clock cycles.
mql5:
3) (TIP) In the example, you could have done with a structure rather than a class, to save a little memory and a couple of hundred clock cycles.
The expert advisor uses the indicator on a different timeframe. On tests in the Expert Advisor appears wrong data from the indicator.
The EA itself works on M5, and the indicator on H4. Indicators which are called on the same timeframe (M5) return the correct values.
Returned values are similar to the indicator values, but are different from the real values which are visible when the indicator is applied to the price chart window.
What is the problem?
Example code of indicator call: