- Questions from Beginners MQL5 MT5 MetaTrader 5
- High/low last bar of yesterday and first bar of today
- How to find the OHLC of a specific trading time range?
- "Last trading day 16:45" is non-sense. Last trading day has nothing to do with 16:45, the day starts at first tick at or beyond 00:00.
- That makes no sense. If the time is now 1650, then there will be a 1650 M1 bar. 1645 is not an M1 but the previous M5 bar.
How To Ask Questions The Smart Way. 2004
Be precise and informative about your problem - iBarShift(_Symbol, PERIOD_M5, TimeCurrent() )+1 is the previous M5 bar.
-
On MT4: Unless the current chart is that specific symbol(s)/TF(s) referenced, you must handle 4066/4073 errors before accessing candle/indicator values.
Download history in MQL4 EA - Forex Calendar - MQL4 programming forum - Page 3 #26 № 4 2019.05.20
- "Last trading day 16:45" is non-sense. Last trading day has nothing to do with 16:45, the day starts at first tick at or beyond 00:00.
- That makes no sense. If the time is now 1650, then there will be a 1650 M1 bar. 1645 is not an M1 but the previous M5 bar.
How To Ask Questions The Smart Way. 2004
Be precise and informative about your problem - iBarShift(_Symbol, PERIOD_M5, TimeCurrent() )+1 is the previous M5 bar.
-
On MT4: Unless the current chart is that specific symbol(s)/TF(s) referenced, you must handle 4066/4073 errors before accessing candle/indicator values.
Download history in MQL4 EA - Forex Calendar - MQL4 programming forum - Page 3 #26 № 4 2019.05.20
Hello William,
Maybe my word made mistake.
For example, everyday has a 16:45 M1 bar, i want to know last trading day 16:45 M1 bar Open price.
For my code, i can get the nearest 16:45 bar. if the current time is smaller than 16:45 beacuse the last trading day 16:45 M1 bar is the nearest one.
However, if the current time greater than 16:45, such as 16:50, the nearest 16:45 M1 bar is today instead of last trading day, so i want to get the last trading day 16:45 M1 bar.
Hope this can make you understand more clearly
You used the same words exactly the same way. Made no sense the first time. Same words, same nonsense.
The last trading day is always today. Same words, same nonsense.
Perhaps you want the previous trading day 16:45 M1 bar.
Find bar of the same time one day ago - MQL4 programming forum 2017.10.06
SECONDS HR1645 = 60300; // (16 × 60 + 45) × 60 datetime yesterdayBOD = yesterday(); INDEX iY1645 = iBarShift(_Symbol, PERIOD_M1, yesterdayBOD + HR1645);
You used the same words exactly the same way. Made no sense the first time. Same words, same nonsense.
The last trading day is always today. Same words, same nonsense.
Perhaps you want the previous trading day 16:45 M1 bar.
Find bar of the same time one day ago - MQL4 programming forum 2017.10.06
i am sorry, you are right. Forgive my English. is "Previous" instead of "Last".
Thanks!
What if yesterday is Sat. ?
If you just used date( date() - 1 ) on Sunday (assuming your broker has Sunday bars,) you would get Saturday, previous calendar day.
If you look at the yesterday function, it finds the last bar not part the day of the passed argument. That can't be Saturday because the market was closed. It can only find a Friday. (or earlier) bar.
If you just used date( date() - 1 ) on Sunday (assuming your broker has Sunday bars,) you would get Saturday, previous calendar day.
If you look at the yesterday function, it finds the last bar not part the day of the passed argument. That can't be Saturday because the market was closed. It can only find a Friday. (or earlier) bar.
is this function only work in MT5 language ?
i cannot make this work in MT4
-
"Doesn't work" is meaningless — just like saying the car doesn't work. Doesn't start, won't go in gear, no electrical, missing the key, flat tires — meaningless.
How To Ask Questions The Smart Way. 2004
When asking about codeDo you really expect an answer? There are no mind readers here and our crystal balls are cracked.
-
Do you see blue words with underlines? Those are links. They take you to more information. Like the one I provided takes you to my function definitions.

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use