-
double close= iClose(_Symbol,PERIOD_H1,0);
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 - MQL4 programming forum - Page 3 #26.4 (2019) - Not tested, not compiled, just typed.Find bar of the same time one day ago - MQL4 programming forum #1 & #6 (2017)
datetime now = TimeCurrent(), today = date(now), endH1 = today + PeriodSeconds(PERIOD_H1) - 1; if(endH1 > now) … // No hour candle yet today. int iBod = iBarShift(_Symbol, _Period, today), iEndH1 = iBarShift(_Symbol, _Period, endH1); double open = iOpen(_Symbol, Period, iBod), close = iClose(_Symbol, Period, iEndH1);
Not tested, not compiled, just typed.
See also Dealing with Time (Part 1): The Basics - MQL5 Articles (2021.10.01)
Dealing with Time (Part 2): The Functions - MQL5 Articles (2021.10.08)
MQL5 Programming Basics: Time - MQL5 Articles (2013.04.26)
-
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 - MQL4 programming forum - Page 3 #26.4 (2019) - Not tested, not compiled, just typed. Not tested, not compiled, just typed.Find bar of the same time one day ago - MQL4 programming forum #1 & #6 (2017)
See also Dealing with Time (Part 1): The Basics - MQL5 Articles (2021.10.01)
Dealing with Time (Part 2): The Functions - MQL5 Articles (2021.10.08)
MQL5 Programming Basics: Time - MQL5 Articles (2013.04.26)
Thank you I appreciate I will test it

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hello I request help in coding the function I will explain below, I have already written some part of the code but I am unable to code a function that identifies the open and close of one hour midnight candle. The logic is that EA identifies one hour midnight candle close and open then drop down to 5 minutes timeframe to open orders based on my breakout conditions. Below is a code I have written but stuck, your help will be appreciated: