Of course, by definition a static array is ... static !
angevoyageur:
Yes, but in previous example, once the value of the parameter is given as an input, then the size of the array is fixed during script/EA execution. Its size changes only if input parameter is changed, so before the EA is being executed.
Of course, by definition a static array is ... static !
hardhu:
Yes, but in previous example, once the value of the parameter is given as an input, then the size of the array is fixed during script/EA execution. Its size changes only if input parameter is changed, so before the EA is being executed.
Send a message to the Service Desk and ask MetaQuotes to change the way mql5 works . . . or just work with what you have.
Yes, but in previous example, once the value of the parameter is given as an input, then the size of the array is fixed during script/EA execution. Its size changes only if input parameter is changed, so before the EA is being executed.
hardhu:
Yes, but in previous example, once the value of the parameter is given as an input, then the size of the array is fixed during script/EA execution. Its size changes only if input parameter is changed, so before the EA is being executed.
What's the problem with dynamic array ?
Yes, but in previous example, once the value of the parameter is given as an input, then the size of the array is fixed during script/EA execution. Its size changes only if input parameter is changed, so before the EA is being executed.
angevoyageur:
What's the problem with dynamic array ?
No, no, there's no problem at all with dynamic array, and, @RaptorUK, I have no complaints at all with the way MQL5 works, it was just a curiosity of mine, that's all.
What's the problem with dynamic array ?
I think the question is indeed reasonable. It's not a stupid question at all. More over, from the documentation one concludes that the size should be known at compile time (similar to C, C++) and iit seems the input parameters are such. I don't understand the reaction on this questions. Though, I think I do but don't want to say about it :)
Alain Verleyen #:
What's the problem with dynamic array ?
What's the problem with dynamic array ?
If you know the amount of data you need to copy, it should better be done to a statically allocated buffer, in order to prevent the allocation of excessive memory.
Documentation on MQL5: Language Basics / Data Types / Dynamic Array Object
- www.mql5.com
Dynamic Array Object - Data Types - Language Basics - MQL5 Reference - Reference on algorithmic/automated trading language for MetaTrader 5
LRDPRDX #: If you know the amount of data you need to copy, it should better be done to a statically allocated buffer, in order to prevent the allocation of excessive memory.
But you do not know.
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
Hello everybody,
I would like to use an array whose size is specified by some input parameter, for example:
But in this way i get an error at compilation:
'[' - invalid index value
Is it then only possible to obtain what I would like by using a a dynamic array and then setting its size with the ArrayResize function inside OnInit, as for example: