Efficient Way To Work With CopyBuffer() From Other Timeframes

 

Hello everyone, I'm learning how to get indicator data from another timeframe. Currently I'm still copying data one by one in a loop.

// Call this function in a loop

double CopyDataHandle(int &handle, datetime startTime, int bufferIndex=0) {
  double data[1];
  int copy;
  copy = CopyBuffer(handle, bufferIndex, startTime, 1, data);
  if(copy > 0) return data[0];
  Print(GetLastError());
  return 0;
}

But I have received comments that it is an ineffective way.

Someone who has a lot of experience working with multi-timeframe indicators please point me suggestions or some ideas to copy data more effectively. 

Thanks in advance.