Any questions from newcomers on MQL4 and MQL5, help and discussion on algorithms and codes - page 1217
![MQL5 - Language of trade strategies built-in the MetaTrader 5 client terminal](https://c.mql5.com/i/registerlandings/logo-2.png)
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 all, I have a question about MQL4
By default, the array is indexed from 0 and in ascending order
Q&A
With which function, or language construct, can the above array be indexed by 10 values with arbitrary integer values and in any order? For example, as below. I would be very grateful if you could demonstrate this method with appropriate code.
![](https://c.mql5.com/3/326/3627868232344__1.png)
Thank you.
Hello all, I have a question about MQL4
By default, the array is indexed from 0 and in ascending order
Q:
With which function, or language construct, can I index the above array to 10 values with arbitrary integer values and in any order? For example, as below. I would be very grateful if you could demonstrate this method with appropriate code.
Thank you.
Shuffle randomly, buffer or indexes(MathRand)
In the indicator in the Alert structure. The 5th line from the bottom isAlert(b);
This appears to be the number of milliseconds since the system started)
Shuffle randomly, buffer or indexes (MathRand)
Regarding arrangement of indexes in random sequence, I understand that this is done using the MathRand() function.
My question is what function can help me replace index values, which are on default (0,1,2,3,4,5,6...9) with necessary for me index values, for example ( 45,90,119,120,234,336,338,564,607,901). I do not need this operation to write an indicator.
Thank you.
Regarding arrangement of indexes in arbitrary sequence, I understand that it is done with MathRand() function.
The question And with help of which function I can replace index values, which are on default (0,1,2,3,4,5,6...9) with necessary for me index values, for example ( 45,90,119,120,234,336,338,564,607,901). I do not need this operation to write an indicator.
Thank you.
Create a second buffer - index buffer.
..or just take a random number and use it to get the buffer value.Fill it with mixed values, from 0 to size_buffer - that's the indexes)
Create a second buffer - an index buffer.
..or just take a random number and use it to get the buffer value.Fill it with shuffled values, from 0 to size_buffer - that's the indexes)
Thanks for the help.
Here is a simple code
In 10 minutes the array will be filled with price values with indexes from 0 to 9.
If you don't mind, please change the code so that the array is filled with the same values, but the indexes of this array are in the following order 45,90,119,120,234,336,338,564,607,901
No need to shuffle the index values yet.
Thanks for the help.
I just don't have any indicators in my strategies. I am not familiar with buffers. As far as I understand the buffer is an element of an indicator.
Thank you for your help.
Here is a simple code
In 10 minutes the array will be filled with price values with indexes from 0 to 9.
If you don't mind, please change the code so that the array is filled with the same values, but the indexes of this array are as follows: 45,90,119,120,234,336,338,564,607,901
No need to shuffle the index values yet.
Thanks for the help.
I just don't have any indicators in my strategies. I am not familiar with buffers. As far as I understand the buffer is an element of an indicator.
Index 901 means there are 902 elements in the array.
No ... There are 10 elements in the array. And these 10 indexes of these 10 elements must be denoted by these values in this sequence (0)45, (1) 90, (2) 119, (3) 120, (4) 234, (5) 336, (6) 338, (7) 564, (8) 607, (9) 901
In parentheses are the former index values. They should be replaced with new values without brackets.
of array elements can be indexed by any sequence of numbers, and not in the order 0,1,2,3,4........100
No ... there are 10 elements in the array. And these 10 indexes of these 10 elements must be denoted by these values in this sequence (0)45, (1) 90, (2) 119, (3) 120, (4) 234, (5) 336, (6) 338, (7) 564, (8) 607, (9) 901
In brackets are the former values of the indices. They should be replaced with new values without brackets.
That is, I can index any number of elements in an array by an arbitrary sequence of numbers, not in the order 0,1,2,3,4........100
Anindex(lat.index means a list, registry, indexer, or index finger) is a number, letter, or other combination of symbols that indicates where an item is located in an array.
Index 45 indicates the 45th element in the list, index 90 indicates the 90th element.
No ... there are 10 elements in the array. And these 10 indexes of these 10 elements must be denoted by these values in this sequence (0)45, (1) 90, (2) 119, (3) 120, (4) 234, (5) 336, (6) 338, (7) 564, (8) 607, (9) 901
In parentheses are the former index values. They should be replaced with new values without brackets.
That is, I can index any number of array elements by any sequence of numbers, and not in the order 0, 1, 2, 3, 4........100
I don't get it, the array index is an index from 0 to N. And what you want is more like a dictionary with hashes. I don't know how to do it in an array and I don't think you can do it in a regular array. There's a Generic class library with dictionaries in MT. That should help.