Indicator problem? (CopyBuffer fails)

 

Hello,

I'm trying to do something VERY simple. All I'm trying to do is get the values of an MA indicator:

 

void OnTick()
  {
//---

   int maHandle;
   maHandle=iMA(NULL,0,14,0,MODE_SMA,PRICE_CLOSE);
   
   // check handle
   if (maHandle!=INVALID_HANDLE) {

      double values[];
      Print("Copy Rates = " + CopyBuffer(maHandle,0,0,100,values));
      Print("Values[0] = " + values[0]);
      
      
      
      
      
      
      
      IndicatorRelease(maHandle);
   
   }
   
  }

 However, CopyBuffer will return -1 every time... all the values are 0...

 I can't figure out why the indicator buffer will not copy? 

 

Did you read documentation? See Note section

it's recommended to get the indicators handles in function OnInit()

See also Timeseries and Indicators Access

In your case indicator data not get ready

Reason: