How can i get the first price close of the day?

 
I'm new to mql4 language. I want to get the first price close of the current day. For example, tomorrow at 00:10 of 9 november i would like to have the price of EURUSD to store inside a variable, that i need to make other calculation.
 
Simone1574:
I'm new to mql4 language. I want to get the first price close of the current day. For example, tomorrow at 00:10 of 9 november i would like to have the price of EURUSD to store inside a variable, that i need to make other calculation.
// Assume today is 9th November 2023 at 00:20:
// The close of yesterday 8th November 2023 will be got from the following code

double YesterdayClosePrice=iClose(NULL, PERIOD_D1, 1);//NULL means your EA is attached to the same chart of the currency pair and the index=1 means yesterday

//Hope it is clear now.
 
Simone1574: . I want to get the first price close of the current day. For example, tomorrow at 00:10 of 9 november i would like to have the price of EURUSD to store inside a variable, that i need to make other calculation.
  1. You can't read tomorrow's prices today.
  2. There is no first close. There is only one close for any unit of time. The closest you can do is read the M1 chart for the candle closest before your stated minute.
    #define HR0010 (600)
    datetime now = timeCurrent();
    if( time(now) < HR0010 ) return; // can't read the future.
    int i0009 = iBarShift(NULL, now) - 1;
    double firstClose = iClose(NULL, PERIOD_M1, i0009);
              Find bar of the same time one day ago - MQL4 programming forum #1 & #6 (2017)

 
datetime when = date(now) + HR0010 - 1;
int i0009 = iBarShift(NULL, PERIOD_M1, when);
correction.
 
Comments that do not relate to this topic, have been moved to "Off-topic MT4/mql4 questions.".
Reason: