![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
It's mostly all on classes, which are a dark forest to me. But, some thoughts have come up. Make an array with dates and numbers separately. Only, how to get the index number where the dates are after sorting, i.e. get the i which is in the second dimension?
double d[215][2];
m[0][i]=Dat_DtTm;
d[i][0]=f1;
d[i][1]=f2;
Did the following:
datetime m2[215];
double d[215][4];
m1[i]=Dat_DtTm;
m2[i]=Dat_DtTm;
d[i][0]=f1;
d[i][1]=0.0;
d[i][2]=f2;
d[i][3]=0.0;
ArraySort(m1,WHOLE_ARRAY,0,MODE_DESCEND);
for (int y=214;y>=0;y--)
{
for (int a=214;a>=0;a--)
{
if (m1[y]==m2[a])
{
d[y][1]=d[a][0];
d[y][3]=d[a][2];
Print("m1[y]=",m1[y],"d[y][1]=",d[y][1],"d[y][3]=",d[y][3],"y=",y);
break;
}
}
}
It's mostly all on classes, which are a dark forest to me. But, some thoughts have come up. Make an array with dates and numbers separately. Only, how to get the index number where the dates are after sorting, i.e. get the i which is in the second dimension?
double d[215][2];
m[0][i]=Dat_DtTm;
d[i][0]=f1;
d[i][1]=f2;
It's a lot simpler than that. Suppose we have a date array, for example datetime m_date[4000] and a lot of other arrays of any type: int, string, double ... and any dimension.
All of them are related in such a way that data in the i-th row of these arrays correspond to date m_date[ i ]. You need to sort all these arrays by date.
Let m_dim be the number of rows in these arrays (number of dates). We will not use ArrayResize as a costly operation, just m_dim <= 4000, in our example.
int m_index[ 4000, 2 ];
// Заполняем массив индексов:
for ( int i = 0; i < m_dim; i ++ )
{
m_index[ i, 0 ] = m_date[ i ];
m_index[ i, 1 ] = i;
}
// Сортируем индексный массив
ArraySort( m_index, m_dim, 0, MODE_DECEND);
// Все
Now from the first dimension we take the date and from the second dimension we take the index of the arrays corresponding to this date
Everything is much simpler. Suppose we have an array of dates, for example datetime m_date[4000] and a bunch of other arrays of any type: int, string, double ... and any dimension
All of them are related in such a way that data in the i-th line of these arrays correspond to date m_date[ i ]. You need to sort all these arrays by date.
Let m_dim be the number of rows in these arrays (number of dates). We will not use ArrayResize as a costly operation, just m_dim <= 4000, in our example.
int m_index[ 4000, 2 ];
// Заполняем массив индексов:
for ( int i = 0; i < m_dim; i ++ )
{
m_index[ i, 0 ] = m_date[ i ];
m_index[ i, 1 ] = i;
}
// Сортируем индексный массив
ArraySort( m_index, m_dim, 0, MODE_DECEND);
// Все
Now from the first dimension we take the date and from the second dimension we take the index of the arrays corresponding to this date