Download MetaTrader 5

How to use ArraySetAsSeries() to the row of a 2D Array?

To add comments, please log in or register
enbo lu
Moderator
1957
enbo lu  

I declare a 2D array and I need to make each row elements being indexed like in time series. 

double a[10][10];
for(i=0;1<10;1++)
{
  ArraySetAsSeries(a[i][],true);
}

 But it didn't work. The compiler says Error: ']' - expression expected 

How should I make it work? 

Thanks in advance .

Alain Verleyen
Moderator
29859
Alain Verleyen  
luenbo:

I declare a 2D array and I need to make each row elements being indexed like in time series. 

 But it didn't work. The compiler says Error: ']' - expression expected 

How should I make it work? 

Thanks in advance .

From the documentation of ArraySetAsSeries() :

Note

The AS_SERIES flag can't be set for multi-dimensional arrays or static arrays (arrays, whose size in square brackets is preset already on the compilation stage). Indexing in timeseries differs from a common array in that the elements of timeseries are indexed from the end towards the beginning (from the newest to oldest data).

Alain Verleyen
Moderator
29859
Alain Verleyen  

You can use a structure instead :

struct arrayasseries
  {
   double ar[];
  };

arrayasseries a[10];

int OnInit()
  {
   for(int i=0;1<10;i++)
     {
      ArraySetAsSeries(a[i].ar,true);
     }
...
  }
enbo lu
Moderator
1957
enbo lu  
angevoyageur:

You can use a structure instead :

Great!  Thank you.
To add comments, please log in or register