Download MetaTrader 5

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

To add comments, please log in or register
Deposit to your account using bank cards via Gate2Shop
enbo lu
Moderator
1947
enbo lu 2013.08.31 04:16 

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
30752
Alain Verleyen 2013.08.31 09:41  
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
30752
Alain Verleyen 2013.08.31 09:53  

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
1947
enbo lu 2013.09.01 03:24  
angevoyageur:

You can use a structure instead :

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