copybuffer error 4807

 

Hi

Trying to use copybuffer for some indicators, but it is returning error 4807 when running. I tried it for stochastics and Adaptive Moving Average, with the same error. Could only make it work for the Simple Move Average.

Thank you

input int                  Kperiod=5;                  
input int                  Dperiod=3;                  
input int                  slowing=3;                  
input ENUM_MA_METHOD       ma_method=MODE_SMA;        
input ENUM_STO_PRICE       price_field=STO_LOWHIGH;   
input string               symbol=" ";   
input ENUM_TIMEFRAMES      period=PERIOD_CURRENT;


int    handle; 

string name=symbol; 


//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()
  {
//---

      MqlParam pars[5]; 
      //--- o período K para cálculos 
      pars[0].type=TYPE_INT; 
      pars[0].integer_value=Kperiod; 
      //--- o período D para suavização primária 
      pars[1].type=TYPE_INT; 
      pars[1].integer_value=Dperiod; 
      //--- o período K final para suavização 
      pars[2].type=TYPE_INT; 
      pars[2].integer_value=slowing; 
      //--- tipo de suavização 
      pars[3].type=TYPE_INT; 
      pars[3].integer_value=ma_method; 
      //--- método de cálculo do Estocástico 
      pars[4].type=TYPE_INT; 
      pars[4].integer_value=price_field; 

      handle=IndicatorCreate(name,period,IND_STOCHASTIC,5,pars); 
   
   
//---
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Expert deinitialization function                                 |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {
//---
   
  }
//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick()
  {
//---

   double _stoch[];

   ArraySetAsSeries(_stoch, true);

   if (CopyBuffer(handle,0,0,20,_stoch) < 0){Print("stoch error =",GetLastError());}
   
   
  }
//+------------------------------------------------------------------+
 
mcronline:

Hi

Trying to use copybuffer for some indicators, but it is returning error 4807 when running. I tried it for stochastics and Adaptive Moving Average, with the same error. Could only make it work for the Simple Move Average.

Thank you

I was defining the symbol the wrong way

changed to:

string name = _Symbol;
Reason: