iDEMA indicator 4806 ? =Requested data not found (ERR_INDICATOR_WRONG_PARAMETERS)

siljo
229
siljo  

Hi

Why I get error 4806 on CopyBuffer?


//+------------------------------------------------------------------+
//|                                                        test1.mq5 |
//|                        Copyright 2021, MetaQuotes Software Corp. |
//|                                             https://www.mql5.com |
//+------------------------------------------------------------------+
//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+

int demaHandle;         // DEMA handle
double demaVal[];       // dynamic array for numerical values of Moving Average

#define  _DEMA_perioda_    12

int OnInit()
  {
//--- create timer
   EventSetTimer(60);
   
   ResetLastError();
   demaHandle=iDEMA(NULL,Period(),_DEMA_perioda_,0,PRICE_CLOSE);   //dema_period=7 ?
//--- Check for Invalid Handle
   if(demaHandle<0)
     {
      Alert("Error in creation of DEMA indicators - error: ",GetLastError(),"!!");
     }

   ArraySetAsSeries(demaVal,true);
   ResetLastError();
   if(CopyBuffer(demaHandle,0,0,3,demaVal)<0)
     {
      Alert("Error copying DEMA indicator buffer - error:",GetLastError());   //4806 ? =Requested data not found (ERR_INDICATOR_WRONG_PARAMETERS)
     }   
//---
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Expert deinitialization function                                 |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {
//--- destroy timer
   EventKillTimer();
   
  }
//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick()
  {
//---
   
  }
//+------------------------------------------------------------------+
//| Timer function                                                   |
//+------------------------------------------------------------------+
void OnTimer()
  {
//---
   
  }
Vladimir Karputov
Moderator
234656
Vladimir Karputov  

OnInit serves for various preparatory actions. You need to receive data in OnTick.

siljo
229
siljo  
siljo:

Hi

Why I get error 4806 on CopyBuffer?


Yes...! Thank you!