MQL5: iCustom + CopyBuffer in different timeframes

 

I have a problem to obtain data buffers using iCustom function

My indicator use another iCustom indicator in 2 different timeframes:

- first iCustom in the PERIOD_CURRENT, 

- second in period daily.

I dont have problem to obtain indicator handle, but when i try to obtain buffer into OnCaculate(), using CopyBuffer, i cannot to get data for my indicator handle with period daily (Copied data is -1).

Below you can see my code.

Somebody can help me to solve my problem.?

Note: this problem doesn't happend when i use the indicator in other EA. In this case, it is possible to compare Bars of the different indicators/TimeFrames, in order to get appropriate data.

  OnInit()
{
/*................*/

    if((indReg =iCustom(NULL,PERIOD_CURRENT,"REGRES.ex5", nBar))==INVALID_HANDLE))
        {
         printf("Error creating ICUSTOM-REGRES indicator");
         return(false);
        }
      if((indRegDay =iCustom(NULL,PERIOD_D1,"REGRES.ex5", 5))
        {
         printf("Error creating ICUSTOM-REG-DAY indicator");
         return(false);
        }
/*******..........................*********/
}

 int OnCalculate(const int rates_total,                 
	const int prev_calculated,                 
	const datetime &time[],                 
	const double &open[],                 
	const double &high[],                 
	const double &low[],                 
	const double &close[],                 
	const long &tick_volume[],                
 	const long &volume[],                 
	const int &spread[])   
{      
 	Copied= CopyBuffer(indReg,0,0,rates_total,BReg);  
     	Copied= CopyBuffer(indRegDay,0,0,rates_total,BRegDay);


 /*************...............................*******************/ 
}
Documentation on MQL5: Technical Indicators / iCustom
Documentation on MQL5: Technical Indicators / iCustom
  • www.mql5.com
[in]  Custom indicator name. If the name starts with the reverse slash '\', the EX5 indicator file is searched for relative to the MQL5\Indicators indicator root directory. Thus, when calling FirstIndicator"...), the indicator is downloaded as MQL5\Indicators\FirstIndicator.ex5. If the path contains no file, the error 4802...
 
Please edit your post and
use the code button (Alt+S) when pasting code
 
Jesus Victor Lerga Bezunartea: i cannot to get data for my indicator handle with period daily (Copied data is -1).

RatesTotal is the number of bars of the current timeframe chart. You don't have that many on the D1 chart.

 
William Roeder:

RatesTotal is the number of bars of the current timeframe chart. You don't have that many on the D1 chart.

Yes, i know.

I've tried also with other  number in "count" parameter , based in Bars function or fixed number (i.e 2, 1...) 

But in any case copied =-1


       int barras=  Bars(NULL,PERIOD_D1);
       
       
       int barrasM=  Bars(NULL,PERIOD_CURRENT);

      
Reason: