How to know close price of Last Friday

 

I want to check the close price of Last Friday (time xxxxxxx)

For example, now Thirthday and 14:00

I want to know the close price of 16:00 on Last Friday.

Below is basic code but I am not sure how to know the time gap  between current xxxx  and Last Friday time xxxxx.

datetime when = ...;
int  iWhenM1 = iBarShift(NULL, PERIOD_M1, when)
double hiWhen = iHigh(Null, PERIOD_M1, iWhenM1);

Please advise!

 

Can you use the close of the previous week?

iClose(NULL, PERIOD_W1, 1);
This should suffice unless there's something I'm missing.
 
Alexander Martinez # unless there's something I'm missing.

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)

 
William Roeder #:

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)

Yup, you definitely want to check for these codes, even moreso if you're running an EA that places trades since you're not around to cycle through timeframes and download the data for that symbol+timeframe.

 
You can reverse browse rates until the bar, watching the week number, for instance.
 
Carlos Albert Barbero Marcos #:
You can reverse browse rates until the bar, watching the week number, for instance.

Maybe check the time gap between current() - 16:00(On Friday) and divided by 1H ?

 
Cromo #: Maybe check the time gap between current() - 16:00(On Friday) and divided by 1H ?

That assumes all bars exist; they don't.