Find period separator

 

Hello everyone,

I'm quite new to MQL4 and haven't yet found a possibility to know if a certain bar is the first of the day (what can easily be done visually in the chart with "Show period separators"). So, what I'd like to have is some function like

bool IsFirstBar(int bar_index)

{

But what would the code for this function be?

}


Thanks in advance,

Andreas



edit: Just looking for the time gap between two bars is not sufficient. There could be bars missing, or daylight saving time was switched during the weekend (this happens in the US two weeks earlier than in Germany for example, so US market is usually open 15:30 till 22:00 local time, but some weeks from 14:30 till 21:00). I hope you get the problem.

 

Hello again,

just wondering if noone knows an answer or if the topic just got lost ;-)

 

Not sure I fully understand your objective, but is the code from cameofx here of any use...

https://www.mql5.com/en/forum/126382

V

 

Hi Viffer,

thanks for the hint, maybe iBarShift with exact = false will do the task. I'll give it a try.

 
if a certain bar is the first of the day
if (TimeDay(Time[1]) != TimeDay(Time[0])) ...
Reason: