calling the RBC range bar indicator from EA

 

Has anyone figured out how to specify the parameter for the rbc-range-bar-chart indicator when calling iCustom"?

All I get is error 4002

After some trial and error the following code executes without error, Just have to wait a while until there is data in the buffers. First call gives zero.

Just have to figure what the buffers contain  :-)

//Global:

  double buffer0[];
  double buffer1[];
  datetime dt = StringToTime("2014.01.01 00:00:00");
  int RBC_Handle = 0;



// In OnInit:

   ArraySetAsSeries(buffer0,true);
   ArraySetAsSeries(buffer1,true);

   
   RBC_Handle = iCustom("EURUSD",PERIOD_M15,"Market\\rbc-range-bar-chart",dt,1,1,1385769600,0,60);
   if(RBC_Handle == INVALID_HANDLE)
   {
     Print("Invalid RBC-Handle!!");
     return INIT_FAILED;
   }

in Ontick:

//Every 5 minutes:

GetRBC(); 

//

bool GetRBC()
 {
     
  int ret1 = CopyBuffer(RBC_Handle,0,0,5,buffer0);
  if(ret1<1)
   {
    Print("CopyBuffer 0 failed  ret1: " + ret1);
    
    return false;
   }
   
  Print("Buffer 0: ret1: " + ret1 + "  buffer:  " + buffer0[1]);
  
  int ret2 =CopyBuffer(RBC_Handle,1,0,5,buffer1);
  if(ret2<1)
   {
    Print("CopyBuffer 1 failed  ret2: " + ret2);
    return false;
   }
  Print("Buffer 1: ret2: " + ret2 + "  buffer:  " + buffer1[1]);
  return true;
 }





Reason: