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).
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); } ... }
You can use a structure instead :
Dear Alain,
This thread is really old but I hope you'll have the opportunity to take a look at my current issue:
I'm trying to port this MQL4 code to MQL5:
int arr[][2]; ... arr[i, 0] = j; ... ArraySetAsSeries(arr, false); ArraySort(arr);
But I got the same error as mentioned here. How would you change this code to be supported in MQL5?
Thanks.
Dear Alain,
This thread is really old but I hope you'll have the opportunity to take a look at my current issue:
I'm trying to port this MQL4 code to MQL5:
But I got the same error as mentioned here. How would you change this code to be supported in MQL5?
Thanks.
I already answered, use a structure. You can't use a multi-dimensional array with functions expecting an unique dimension.
MQL4 or MQL5 doesn't make a difference here.
Hi, your example is for 1D array?
I'm trying this way but looks wrong... I have array signal[][] as global variable but terminal return warning "see previous declaration of signal" but if I delete it a lot of errors appear....
OnInit>>>
arrayasseries signal[8][210];
for(int i = 0; 1 < 210; i++)
{
ArraySetAsSeries(signal[i][i].ar, true);
}
>>>
while the structure out of all

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
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 .