How can I make the 2nd dimension of an array to be dynamic?

 

Hi all,

I want to record time[0] and time[1] every tick on individual row of an array, i.e. on every new tick, a new row should be opened to record the figures.

here are my code:

datetime a[0,dm2,1];
int dm2=0;

start()
{
   a[0,dm2,0] = iTime(NULL,0,0);
   a[0,dm2,1] = iTime(NULL,0,1);
   dm2++;

   return;
}

as ArrayResize is only for first dimension only, I have no idea how to resize 2nd dimension (or, is it possible to let the 2nd dimension be dynamic in MQL4?)

Can anyone share your experience?

Thank you.

remark:

I have read the coding inside this article but, according to my standard, I really can't understand it: https://www.mql5.com/en/forum/106412

I also have read this article many times: https://book.mql4.com/variables/arrays

I also have read this too: https://www.mql5.com/en/forum/130330

 
wing:
I want to record time[0] and time[1] every tick on
as ArrayResize is only for first dimension only,
  1. If you are recording 2 things, the second dimension is constant. datetime times[][2]; ArrayResize(times,n+1); times[n][0]=...; times[n][1]=...;
  2. Otherwise use separate arrays. datetime times0[], times1[]; arrayresize(); arrayResize(); times0[n]=...; times1[n]= ...;
  3. Why are you using iTime(NULL,0,x) when the simpler Time[x] will do?
  4. Why are you recording those times, they will not be changing during the current candle?
 

1 & 2. that's ok, I will try another method to achieve the same purpose.

3 & 4. people here saying time by time that either you have to learn yourself or pay here, if you want to learn, you have to post your code.

It is because I am not good in coding skill, the original coding is really a mess (and is very complicated). As a result, code posted above this time is for learning purpose only, what I want to know is whether MQL4 allowed 2nd dimension of an array to be dynamic (and how in case of yes).

Anyway, your help is really appreciated, thanks a lot.

 
wing:
3 & 4. people here saying time by time that either you have to learn yourself or pay here, if you want to learn, you have to post your code.

what I want to know is whether MQL4 allowed 2nd dimension of an array to be dynamic (and how in case of yes).
  1. Learn or pay refers to people that aren't asking a question, they don't want to learn, they are just saying 'code this for me.' If you are asking a question about your code, there's no mind readers here, you have to post your code.
  2. If you want a dynamic second dimension you'll have to do it yourself.
 

done.

thank you!