iTime Function always return 0:00 ?

 

Hi,

I've a question regarding iTime function.

datetime today = iTime(_Symbol, PERIOD_D1, 0);

This return 2023.09.20 15:04:08.948 Test (EURUSD,M5) 2023.09.20 00:00:00

For XAUUSD the open time is 2023.09.20 01:00:00

however the return is actually

2023.09.20 15:05:09.729 Test (XAUUSD,H1) 2023.09.20 00:00:00

Is it normal behaviour?

In that case, how to get the correct open datetime?

 

Dua Yong Rew: I've a question regarding iTime function.

This return 2023.09.20 15:04:08.948 Test (EURUSD,M5) 2023.09.20 00:00:00

For XAUUSD the open time is 2023.09.20 01:00:00

however the return is actually

2023.09.20 15:05:09.729 Test (XAUUSD,H1) 2023.09.20 00:00:00

Is it normal behaviour?

In that case, how to get the correct open datetime?

Yes, that is normal behaviour, because for Daily bars/candles, the opening time is ALWAYS 00:00, no matter what time of the day the first tick arrived.

For each time frame, the opening time is truncated to the start of the time-frame time. For example, Hour bars always open on the hour even if the first tick came in several minutes later within the hour.

You can either analyse the tick data to get the time of the first tick, or analyse the M1 data to get the time of the first minute bar/candle (which will be truncate to the start of the minute).

 
Fernando Carreiro #:

Yes, that is normal behaviour, because for Daily bars/candles, the opening time is ALWAYS 00:00, no matter what time of the day the first tick arrived.

For each time frame, the opening time is truncated to the start of the time-frame time. For example, Hour bars always open on the hour even if the first tick came in several minutes later within the hour.

You can either analyse the tick data to get the time of the first tick, or analyse the M1 data to get the time of the first minute bar/candle (which will be truncate to the start of the minute).

Thank you

I guess more work needed to just get the correct opening time