Know the open or close TIME of a candle by shift number

 
Hello,

I wonder if it is possible to retrieve the hours: minutes of a candle defined by its shift.


My indicator goes all the candles one by one, I would like him to back the opening date of the candle ..

Is there a function in MQL4 for this?


Thanks in advance.

 
jal_fr:
Hello,

I wonder if it is possible to retrieve the hours: minutes of a candle defined by its shift.


My indicator goes all the candles one by one, I would like him to back the opening date of the candle ..

Is there a function in MQL4 for this?


Thanks in advance.

How about this ...

datetime Time[]
Series array that contains open time of each bar of the current chart. Data like datetime represent time, in seconds, that has passed since 00:00 a.m. of 1 January, 1970.

Series array elements are indexed in the reverse order, i.e., from the last one to the first one. The current bar which is the last in the array is indexed as 0. The oldest bar, the first in the chart, is indexed as Bars-1.
 
Hey, i found
datetime iTime( string symbol, int timeframe, int shift)

Thanks ! dabbler
 
jal_fr:
Hey, i found
datetime iTime( string symbol, int timeframe, int shift)

Thanks ! dabbler
Whilst you could use iTime(NULL,0,n) to refer to bar n on the current chart and the current timeframe, it is easier to just use Time[n]. Of course if you want a different symbol or a different timeframe then you do need to use iTime.
 
jal_fr:
I wonder if it is possible to retrieve the hours: minutes of a candle defined by its shift.
int         shift   = ...;
datetime    Tshift  = Time[shift];
Print(  "A shift of ", shift, " corresponds to ",
        TimeToStr(Tshift, TIME_MINUTES|TIME_SECONDS) );
Print(  "A shift of ", shift, " corresponds to Hour=", TimeHour(Tshift), 
        " minute=", TimeMinute(Tshift) );