Im Lost with hour Filtering
2 replies
gentmat
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);
}
tomas262
8 years ago #131345
gentmat
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
Viewing 2 replies - 1 through 2 (of 2 total)