Too much memory use on Multiple iCustom calls

 

Hi folks,

I am trying to retrieve history data from MT4 to build a model with. The problem I have is that I need to load the values of a custom indicator into a 3 dimensional array and when i try to run the Expert is history, it does not work, and gives the alert: "not eough memory for EX4 file" and "Global Initialization failed".

I have narrowed the problem down to too many calls of the iCustom function leading to memory overload. Please can you assist with a solution to this problem. Here is the part of the code that is problematic:

      double buyTempC[1][26][25]  = {0};// 
      double sellTempC[1][26][25] = {0};// 

      for (int i = 6; i <= 30; i ++)
          {
          // --- Load the price correlation
          buyTempC[0][0][i-6]   = iCustom(_Symbol,Period(),"pCorr",i,0,0);
          sellTempC[0][0][i-6]  = iCustom(_Symbol,Period(),"pCorr",i,0,0);
          
          for (int j = 6; j <= 30; j++)
              {
              // --- Load the corr correlation
              buyTempC[0][j-5][i-6]    = iCustom(_Symbol,Period(),"cCorr",i,j,0,0);
              sellTempC[0][j-5][i-6]   = iCustom(_Symbol,Period(),"cCorr",i,j,0,0);
              }
          
          }


Thanks Manni