CopyRates seems not working

 

Hi Guys,

in my code CopyRates seems not working well. Testing with M15, I was expecting to have 4 or 5 bars copied, instead just 1.

Why?


for(int i=limit; i<rates_total && !IsStopped(); i++)
     {

      TimeToStruct(time[i],str);
      datetime start=time[i]-PERIOD_M5*60;
      datetime target=time[i]+Period()*60;
      Print("start"+start+" target"+target);

      target=(target<=TimeCurrent())?target:TimeCurrent();

      int copied=CopyRates(Symbol(),PERIOD_M1,start,target,rates);
      Print("Rates:"+rates_total+" copied:"+copied);



 

Did you set limit so you have five (5) history bars?
          How to do your lookbacks correctly.

Did you set time[] as non-series?

 
William Roeder:

Did you set limit so you have five (5) history bars?
          How to do your lookbacks correctly.

Did you set time[] as non-series?

Solved:

To load bars I use

 int op=Bars(Symbol(),PERIOD_M5,start,target);


The true problem was  borker did not give me all bars for that period in that date.

Thanks