NEED HELP! Having problem using TimeCurrent

 
good evening ,I am cooding an EA which trade 2 hour in London open (9:30 to 11:30,Server time).so i used the code
if(((((Londonopen<Hour())&&(Hour()<Londonclose))&&((LondonM<Minute())&&(Minute()<LondonN)))||(((NYorkopen<Hour())&&(Hour()<NYorkclose))&&((NYorkM<Minute())&&(Minute()<NYorkN))))&&(OrdersTotal()==0))

 but the problem is it trades from 9:00 to 9:30,then 10:00 to 10:30.

then i used the following code

if((((Londonopen<currentTime)&&(currentTime<Londonclose))||((NYorkopen<currentTime)&&(currentTime<NYorkclose)))&&(OrdersTotal()==0))

 but am trying to input LondonOpen=9:30,it is showing error.

Please Advice. 

 

You could input your times as decimals. Instead of 9:30, input 9.30 as a double.

//Global

  input double LondonStart=9.30;
  input double LondonEnd=11.30;
  int LondonStartHour=(int)MathFloor(LondonStart);
  int LondonStartMinutes=(int)((LondonStart-LondonStartHour)*100);
  int LondonStartSeconds=LondonStartHour*3600+LondonStartMinutes*60;
  int LondonEndHour=(int)MathFloor(LondonEnd);
  int LondonEndMinutes=(int)((LondonEnd-LondonEndHour)*100);
  int LondonEndSeconds=LondonEndHour*3600+LondonEndMinutes*60;

//In main code

  datetime today_midnight=TimeCurrent()-(TimeCurrent()%(PERIOD_D1*60));
  datetime London_open=today_midnight+LondonStartSeconds;
  datetime London_close=today_midnight+LondonEndSeconds;
  
  if(TimeCurrent()>=London_open && TimeCurrent()<London_close)
    {
    //do something
    }
    
 
GumRai:

You could input your times as decimals. Instead of 9:30, input 9.30 as a double.

 

thanks,man.you saved me from a lot of hassle.
 
tanim:
thanks,man.you saved me from a lot of hassle.

You're welcome

I just realised that I didn't finish my post, I intended to Edit the SRC as the values should be calculated in init. Otherwise changing the inputs will have no effect unless the EA is removed and re-attached.

It should be

 
//Global

  input double LondonStart=9.30;
  input double LondonEnd=11.30;
  int LondonStartSeconds;
  int LondonEndSeconds;

//init

  int LondonStartHour=(int)MathFloor(LondonStart);
  int LondonStartMinutes=(int)((LondonStart-LondonStartHour)*100);
  LondonStartSeconds=LondonStartHour*3600+LondonStartMinutes*60;
  int LondonEndHour=(int)MathFloor(LondonEnd);
  int LondonEndMinutes=(int)((LondonEnd-LondonEndHour)*100);
  LondonEndSeconds=LondonEndHour*3600+LondonEndMinutes*60;

//Main Code

  datetime today_midnight=TimeCurrent()-(TimeCurrent()%(PERIOD_D1*60));
  datetime London_open=today_midnight+LondonStartSeconds;
  datetime London_close=today_midnight+LondonEndSeconds;
  
  if(TimeCurrent()>=London_open && TimeCurrent()<London_close)
    {
    //do something
    }