Reply

Im Lost with hour Filtering

2 replies

gentmat

Customer, bbp_participant, community, 234 replies.

Visit profile

8 years ago #113952

How can i make the ea trade only from :

 

17 pm to 5 am

Hour > 17 && Hour < 5 am

 

If the clock is 3 am the ea wont work because its 2 days spans . 

So how can i tell ea that if close > open then its another day 

 

like this function 

 

 

if(CloseHour>OpenHour) //within the day
   {
      if (OpenHour < TimeHour(TimeCurrent()) && TimeHour(TimeCurrent()) < CloseHour)
         {
         Comment(“Open For Trading”);
         return(true);
         }
      if (OpenHour == TimeHour(TimeCurrent()))
      {
         if(OpenMin<=TimeMinute(TimeCurrent()))
         {
         Comment(“Open For Trading”);
         return(true);
         }
         return(false);
      }
      
      if (CloseHour == TimeHour(TimeCurrent()))
      {
         if(CloseMin>=TimeMinute(TimeCurrent()))
         {
         Comment(“Open For Trading”);
         return(true);
         }
         return(false);
      }
      Comment(“Closed”);
      return(false);
   }
   if(OpenHour>CloseHour)  //Spanning two days
   {
      if (CloseHour < TimeHour(TimeCurrent()) && TimeHour(TimeCurrent()) < OpenHour)
         {
         Comment(“Closed”);
         return(false);
         }
      if (OpenHour == TimeHour(TimeCurrent()))
      {
         if(OpenMin<=TimeMinute(TimeCurrent()))
         {
         Comment(“Open For Trading”);
         return(true);
         }
         return(false);
      }
      if (CloseHour == TimeHour(TimeCurrent()))
      {
         if(CloseMin>=TimeMinute(TimeCurrent()))
         {
         Comment(“Open For Trading”);
         return(true);
         }
         return(false);
      }
      Comment(“Open For Trading”);
      return(true);
   }

0

tomas262

Administrator, sq-ultimate, 2 replies.

Visit profile

8 years ago #131345

Hi, this could work

 

if ((Hour >= 17 AND Hour = 0 AND Hour < 5)) then Time = OK

0

gentmat

Customer, bbp_participant, community, 234 replies.

Visit profile

8 years ago #131356

True Tomas but its just pain for optimizing hours such way . Anyway seems i ll put it like this until now . Thank you

0

Viewing 2 replies - 1 through 2 (of 2 total)