Get value from iBarShift(). - page 2

 
Vladimir Karputov #:

I do not have telepathic abilities - insert your code correctly and I can help you.

I have done that. thanks.

 
"Return Value

The index of the bar corresponding to the specified time. If the bar corresponding to the specified time is not found (there is a gap in the history), the function returns -1 or the index of the nearest bar (depending on the 'exact' parameter)."

Did you try setting the exact parameter to false? 
 
Tobias Johannes Zimmer #:
"Return Value

The index of the bar corresponding to the specified time. If the bar corresponding to the specified time is not found (there is a gap in the history), the function returns -1 or the index of the nearest bar (depending on the 'exact' parameter)."

Did you try setting the exact parameter to false? 

Yes, it is false, I did not change it since that is the default value.

 

An example of how to work in the indicator using 'iBarShift' when requesting data from someone else's timeframe is in the indicator.

The main thing: it is always necessary to check - what did the function return? Is there an error?

   for(int i=limit; i<rates_total; i++)
     {
      int index_tf_0=iBarShift(Symbol(),Inp_TF_0,time[i],false);
      if(index_tf_0<0)
         return(0);
      double price_tf_0=iClose(Symbol(),Inp_TF_0,index_tf_0+1);
      ClosePriceTF0Buffer[i]=price_tf_0;

      int index_tf_1=iBarShift(Symbol(),Inp_TF_1,time[i],false);
      if(index_tf_1<0)
         return(0);
      double price_tf_1=iClose(Symbol(),Inp_TF_1,index_tf_1+1);
      ClosePriceTF1Buffer[i]=price_tf_1;

      MedianPriceBuffer[i]=(price_tf_0+price_tf_1)/2.0;
     }
 
Vladimir Karputov #:

An example of how to work in the indicator using 'iBarShift' when requesting data from someone else's timeframe is in the indicator.

The main thing: it is always necessary to check - what did the function return? Is there an error?

Okay, thanks. I would figure something out. Am looking for why/when the iBarShift() would have a value. The code is suppose to run once per new candle.