Can't get third buffer from CopyBuffer

 

I want to get some values from my indicator to EA. But can get only from first buffer, how to get values from other buffers?

In example below, i try to get values from third buffer, and always get 4806 error. When I try to get from first buffer, everything is all right. I tested it in strategy tester

int OnInit()
  {
   Indicator=iCustom(NULL,0,"Indicat", InpReversalMode, InpPips, InpPercent, _suppRessPercent);
    if(Indicator> 0)
      {
       Print(Indicator);
      }

   return(INIT_SUCCEEDED);
  }

void OnTick()
  {
      bars=Bars(_Symbol,_Period);
      if(BarsCalculated(Indicator)==bars)
      {
         ArraySetAsSeries(value,true);
         ResetLastError();
         if(CopyBuffer(Indicator,2,0,3, value) <= -1)
         {
            Sleep(50);
            for(int i=0;i<100;i++)
            {
               if(BarsCalculated(Indicator)>0)
                  break;
               Sleep(50);
            }
            if(CopyBuffer(Indicator,2,0,3, value) == -1)
            {
               Print("Error getting buffer: ", GetLastError());
            }
         }
         else
            Print(" buffer copied successfully");
      }
 }

 



 
Eggo:

I want to get some values from my indicator to EA. But can get only from first buffer, how to get values from other buffers?

In example below, i try to get values from third buffer, and always get 4806 error. When I try to get from first buffer, everything is all right. I tested it in strategy tester. 

 



Have another look at the iCustom documentation, in particular the "mode" parameter


 

double  iCustom(
   string       symbol,           // symbol
   int          timeframe,        // timeframe
   string       name,             // path/name of the custom indicator compiled program
   ...                            // custom indicator input parameters (if necessary)
   int          mode,             // line index
   int          shift             // shift
   );
Reason: