Failed to copy data from the indicator, error code 4806

 

I have been trying to work with error 4806 and I am a newbie I hope someone can help me to fix it

I declared the double indicator and in the compile they give absolutely no errors until I check the field value

int OnInit()
{
   MA_SET     MA_1 = { 34 };
   MA_SET     MA_2 = { 89 };
   MA_SET     MA_3 = { 200 };

         ArrayResize(STT_iMA,3,0);
         ST (STT_iMA[0],MA_1);
         ST (STT_iMA[1],MA_2);
         ST (STT_iMA[2],MA_3);  
}
//==================
double iRSIGet(const int handle, const int index) 
{
   double RSI[1];
   ResetLastError();
   if(CopyBuffer(handle, 0, index, 1, RSI) < 0) {
      PrintFormat("Failed to copy data from the iRSI indicator, error code %d", GetLastError());
      return(0.0);
   }
   return(RSI[0]);
}
//==================
double iMAGet(const int handle, const int index) 
{
   double MA[1];
   ResetLastError();
   if(CopyBuffer(handle, 0, index, 1, MA) < 0) {
      PrintFormat("Failed to copy data from the iMA indicator, error code %d", GetLastError());
      return(0.0);
   }
   return(MA[0]);
}
//==================
void S_13_Indicator()
  {
   handle_iMA =  iMA( Symbol() , PERIOD_M15, Period_iMA, 1,MODE_EMA,PRICE_CLOSE);
   handle_iRSI = iRSI( Symbol() , PERIOD_H1, 14 ,PRICE_CLOSE);
      Indi_iMA_15   = iMAGet  (handle_iMA,1) ;
      Indi_iRSI_H1  = iRSIGet (handle_iRSI,1);
  }

- Failed to copy data from the iRSI indicator, error code 4806 

- Failed to copy data from the iMA indicator, error code 4806

Can someone please help me figure out what I did wrong. Thanks

 

Discussed dozens of time on this forum.

Please do a search before you post https://www.mql5.com/en/search#!keyword=error%204806

 
Alain Verleyen # :

Thảo luận tranh luận hàng chục lần trên diễn đàn này.

Vui lòng thực hiện tìm kiếm trước khi bạn đăng https://www.mql5.com/vi/search#!keyword=error%204806

Thanks . i got what you mean, i worked with that but all my iMA value declarations and above are invalid

i used ArrayResize above, maybe I should change that to match

 

Improperly formatted code removed by moderator. @FXAI Please EDIT your post and use the CODE button when you insert code.

Code button in editor

This change should fix the error code 4806 issue. If the error persists, double-check your handle initialization and make sure the timeframes and periods used for iMA and iRSI are appropriate for your strategy.