Download MetaTrader 5

iBarShift returns Friday last bar

To add comments, please log in or register
stitchtrader
134
stitchtrader  

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

Alain Verleyen
Moderator
31184
Alain Verleyen  

Hi,

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

stitchtrader
134
stitchtrader  
angevoyageur:

Hi,

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

Hi Alain,
Thank you so much

Alain Verleyen
Moderator
31184
Alain Verleyen  
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 ?

Enrico Lambino
4361
Enrico Lambino  

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);
To add comments, please log in or register