Download MetaTrader 5

Run EA on Filtered Hours?

To add comments, please log in or register
Sherif Hasan
7425
Sherif Hasan  

Hello,

I have coded EA to run on specified hours.

EA setting as 10.00 - 13.00, so it works for 10.00-13.00. but when i edit the settings as 10.30 - 13.30. which EA starts from 11 and ended with 13.30. what could be the problom?

{
    double datetime = TimeLocal();
    double hour0 = TimeHour(datetime);
    
    if ((HoursFrom < HoursTo && hour0 >= HoursFrom && hour0 < HoursTo) ||
    (HoursFrom > HoursTo && (hour0 < HoursTo || hour0 >= HoursFrom)))
    {
        Arrow();
        
    }
    
} 
Simon Gniadkowski
Moderator
18056
Simon Gniadkowski  
sheriffonline :

Hello,

I have coded EA to run on specified hours.

EA setting as 10.00 - 13.00, so it works for 10.00-13.00. but when i edit the settings as 10.30 - 13.30. which EA starts from 11 and ended with 13.30. what could be the problom?

So you are comparing a int (TimeHour) with a double ( HoursFrom and HoursTo ) and you are comparing your Local Timezone with ServerTime . . . and you wonder why you are having issues ?
Sherif Hasan
7425
Sherif Hasan  
RaptorUK :
So you are comparing a int (TimeHour) with a double ( HoursFrom and HoursTo ) and you are comparing your Local Timezone with ServerTime . . . and you wonder why you are having issues ?

yes. you said correct.
Sherif Hasan
7425
Sherif Hasan  

Can anyone support me?

I want to run EA on filtered hours and minutes.

eg: EA should run at 10.30AM to 18.30PM. what is the easiest way to code?

Simon Gniadkowski
Moderator
18056
Simon Gniadkowski  
sheriffonline:

Can anyone support me?

I want to run EA on filtered hours and minutes.

eg: EA should run at 10.30AM to 18.30PM. what is the easiest way to code?

You know what is wrong, fix your code . . .
Boeing747
241
Boeing747  
sheriffonline:

Can anyone support me?

I want to run EA on filtered hours and minutes.

eg: EA should run at 10.30AM to 18.30PM. what is the easiest way to code?

extern int t1 = 1030; // 10:30 time server
extern int t2 = 1830; // 18:30 time server


int start();
{
  
  int d = 100 * Hour() + Minute();

  if ( d < t1 || d > t2 )
  {
   return;
  }

  // your ea code


return;
} 
Tjipke de Vries
6433
Tjipke de Vries  
Boeing747:
almost possible also t1>t2
extern int t1 = 1030; // 10:30 time server
extern int t2 = 1830; // 18:30 time server


int start();
{
  
  int d = 100 * Hour() + Minute();

  if ((( d < t1 || d > t2 )&& t1 < t2)||(( d < t2 && d > t1 )&& t1 > t2))
  {
   return;
  }

  // your ea code


return;
} 
Sherif Hasan
7425
Sherif Hasan  
RaptorUK:
You know what is wrong, fix your code . . .


Found my mistake. now fixed. Thanks for the support.
To add comments, please log in or register