Download MetaTrader 5

Indicator problem? (CopyBuffer fails)

To add comments, please log in or register
Looking for like-minded people? You will find lots of them on the Forum!
Jason
154
Jason 2012.05.25 23:53 

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? 

Slawa
Moderator
6841
Slawa 2012.05.28 10:29  

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

To add comments, please log in or register