Use the technical indicators functions to get value,but can't test in history,Please Help。Thank you very much.

 

Hi,

I want to get a value of Moving Average Indicator,I use the  technical indicators method to get a value.

I use the way on OnInit()  method  of ea.  it is ok on realtime, but, on history for test is fail,

because the value of the handle is always 10 and the CopyBuffer()  method is eror,the error code is 4806.

Please help me,Thank you very much.

Have a good time.

double getIMA()
  {
    maHandle = iMA(Symbol(),0,5,0,MODE_SMA,PRICE_CLOSE);
   double X,mas[];
   ArraySetAsSeries(mas, true);
   if(CopyBuffer(maHandle,0,0,200,mas)!=-1)
      X=mas[1];
   else
      Print(GetLastError());
   return X;
  }
int maHandle;
int OnInit()
  {
   getIMA();
   EventSetTimer(60);
   return(INIT_SUCCEEDED);
  }
 
Jian Ming Xu:

Hi,

I want to get a value of Moving Average Indicator,I use the  technical indicators method to get a value.

I use the way on OnInit()  method  of ea.  it is ok on realtime, but, on history for test is fail,

because the value of the handle is always 10 and the CopyBuffer()  method is eror,the error code is 4806.

Please help me,Thank you very much.

Have a good time.

Don’t try to get data during Oninit. Get the handle then and the data after as the data may not yet be available to the indicator/ea
 
Paul Anscombe #:
Don’t try to get data during Oninit. Get the handle then and the data after as the data may not yet be available to the indicator/ea

Thank you very much.
Have a good time.