MQL5 Array - did you forget array subscript []?

 

Hi there,

Bellow code works perfectly in MQL4:

void HMA07_LINES_ARRAY(int &HMA07_LINES_ARRAYx[])
{   
      HMA07 b=0;
      int result2[];
      int n = EnumToArray(b, result2, -100, 100);
  
      int HMA07_ENUMSIZE = n;
      ArrayResize(HMA07_LINES_ARRAYx,HMA07_ENUMSIZE,HMA07_ENUMSIZE); 
      
      for (int i=1; i < HMA07_ENUMSIZE; ++i) {
               HMA07_LINES_ARRAYx[i-1] = StrToInteger( EnumSplit(EnumToString(HMA07(i)),"_",2) ) ;
      } 

      ArraySort(HMA07_LINES_ARRAYx,WHOLE_ARRAY,0,MODE_DESCEND); 
}


   int HMA07_LINES_ARRAY[];
   HMA07_LINES_ARRAY(HMA07_LINES_ARRAY);


Changed like bellow for MQL5:

void HMA07_LINES_ARRAY(int &HMA07_LINES_ARRAYx[])
{   
      HMA07 b=0;
      int result2[];
      int n = EnumToArray(b, result2, -100, 100);
  
      int HMA07_ENUMSIZE = n;
      ArrayResize(HMA07_LINES_ARRAYx,HMA07_ENUMSIZE,HMA07_ENUMSIZE); 
      
      for (int i=1; i < HMA07_ENUMSIZE; ++i) {
               //HMA07_LINES_ARRAYx[i-1] = StrToInteger( EnumSplit(EnumToString(HMA07(i)),"_",2) ) ;
               HMA07_LINES_ARRAYx[i-1] = (int)( EnumSplit(EnumToString(HMA07(i)),"_",2) ) ;
      } 

      //ArraySort(HMA07_LINES_ARRAYx,WHOLE_ARRAY,0,MODE_DESCEND); 
      ArraySort(HMA07_LINES_ARRAYx); 
}


   int HMA07_LINES_ARRAY[];
   HMA07_LINES_ARRAY(HMA07_LINES_ARRAY);


Error in this line:    HMA07_LINES_ARRAY(HMA07_LINES_ARRAY);


The error messages

  • unexpected token '(', did you forget array subscript []?
  • 'HMA07_LINES_ARRAY' - some operator expected

  • And I don't have any clue how to fix it

    Please help - thank you

     

    Why do array and function have the same identifiers (names)?

    Try to make the names for the array and the function different. If this doesn't help, then post mql4 code that can be compiled (not a snippet where you call a function from the global scope)