iBarShift returns Friday last bar

 

Hi -:D 

I use such an amazing function iBarShift made by Alain (Thank you Alain!)

I've got a little problem. 

iBarShift(Symbol(),PERIOD_H1,D'2014.10.13 00:00');

This returns an accurate bar shift in most of symbols.
But at the beginning of week with some symbols such as S&P500, 
it returns Friday last bar !

It is because the Monday first bar starts at 1:00 (not 0:00) on the H1 and lower timeframe.
Though, it starts at 0:00 on the H2 and higher timeframe, oddly.

How can I improve the iBarShift function in this case ?

Thank you for your advice

 

Hi,

Thank for reporting this issue, I will check and try to improve this function.

 
angevoyageur:

Hi,

Thank for reporting this issue, I will check and try to improve this function.

Hi Alain,
Thank you so much

 
stitchtrader:

Hi -:D 

I use such an amazing function iBarShift made by Alain (Thank you Alain!)

I've got a little problem. 


This returns an accurate bar shift in most of symbols.
But at the beginning of week with some symbols such as S&P500, 
it returns Friday last bar !

It is because the Monday first bar starts at 1:00 (not 0:00) on the H1 and lower timeframe.
Though, it starts at 0:00 on the H2 and higher timeframe, oddly.

How can I improve the iBarShift function in this case ?

Thank you for your advice

Sorry but there is no error.

If a bar doesn't exist, iBarShift returns the nearest previous bar. It's expected and consistent with mql4 version.

What are you expecting and why ?

 

I am thinking that maybe the optional argument 'exact' just needs to be used:

iBarShift(Symbol(),PERIOD_H1,D'2014.10.13 00:00',true);
Reason: