slightly wrong: the declaration number is the size. So the first array is of 51 elements, and the second is an indefinite number as a multiple of 6; "dynamic" as you say.
You access elements by a zero based index, which would be 0-50 for the first array, and 0-5 for the second dimension of the second array.
Hello Ralph!
Thank you very much for your reply!
So if my understanding is correct,
would result in:
0
.
.
.
50
and
[CODE] int x = 2 ;
int data_x[x][6];would result in something like:
0 0
1 1
2 2
3 3
4 4
5 5
?
The first is right. The first element has index 0, second index 1, and so forth, with each n:th element having index n-1, up to the 51:st element.
The second is probably right thinking as well, assuming there is an invisible column heading of "0" for the first column and "1" for the second column. It's a fair enough interpretation to think of the first index as telling which column to look in, and the second index as telling which row (of that column).
Hello Ralph!
Thank you again for your time. It is very helpful!
Working with Arrays
Here's what I'm trying to create:
I'm trying to create some sort of "price density" indicator. Which measures how many times in a given set of bars a specific price is reached. The bar rankings are associated with a specific color so that I would have a field of color helping me visualize a set of support and resistance lines, sort of like what you see attached.
The color is based on how many bars go through that line.
I realize that I would need some sort of two dimensional array to accomplish this. How do I go about putting together that array?
Hey you!
I'm searching exactly something like you made here, are you already finished? Do you have that code for me?
thanks for any help,
Jacob
![MQL5 - Language of trade strategies built-in the MetaTrader 5 client terminal](https://c.mql5.com/i/registerlandings/logo-2.png)
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hello Everyone!
I am trying to understand how to programme arrays in MQL4. Can you please let me know if my interpretations are correct?
the above declares a single dimension 52 element array of integers with default value 0.
[CODE]int data_x[][6];the above declares declares a two dimensional array, one dynamic, and one of 7 element array of integers with default value 0.
Many thanks,