A question about Constant Time

 

Hi guys.


I am not a coder and I need some help...


My question is about how can I capture an hour with minutes as a constant data. I have tried by some ways but I can not to do it.


Mi intention is to compare the constant data with the open time of the bar in order to obtain if that bar is in a sesion of Tokyo, or in a sesion of London, or in the two sesions, etcetera.

These two lines are wrong, according to the compiler:

datetime SydneyBegin = D'00:00';// Open Australia Session
string SydneyEnd = D'09:00:00';// Close Australia Session


I know that I can try with something like this:

extern int SydneyBegin = "00:00";
extern int SydneyEnd = "09:00";

but, I want to be able to compare the constant (the hour independent of the day) to the open time of the bar. This is the lines I am writing to compare the data:


for(int i=limit-1; i>=0; i--)
{
datetime BarTime = iTime(NULL, 0, i);

if(BarTime>=SydneyBegin && BarTime<=SydneyEnd) Sydney[i]=1;
if(BarTime>=TokyoBegin && BarTime<=TokyoEnd) Tokyo[i]=2;
if(BarTime>=LondonBegin && BarTime<=LondonEnd) London[i]=3;
if(BarTime>=USABegin && BarTime<=USAEnd) USA[i]=4;

}

Compilation says:

'00:00' - date literal string is incomplete C:\Program Files\FXDD - MT41\experts\indicators\##_amb_Panel_i-Sessions.mq4 (28, 24)
'09:00:00' - date literal string is incomplete C:\Program Files\FXDD - MT41\experts\indicators\##_amb_Panel_i-Sessions.mq4 (29, 27)

How can I have a constant of the hour, for example 03:00:00? I want that the data hour could be independent of the data day, because always it is the same hour to start the sesion.


Thanks for your atention.


gus

 

See the function TimeHour()...


extern int SydneyBegin = 0;
extern int SydneyEnd = 9;

if(TimeHour(Time[0]) == 9) then the chart hour is 9

 
phy:

See the function TimeHour()...


extern int SydneyBegin = 0;
extern int SydneyEnd = 9;

if(TimeHour(Time[0]) == 9) then the chart hour is 9



Thank you very much, phy. I fixed my errors.


gus