I have add this Trading Hours code to an EA
bool TimeCondition()
{
bool result = false;
datetime SessionStart = StrToTime(StartHour+":"+StartMinute);
datetime SessionEnd = StrToTime(EndHour+":"+EndMinute);
if (StartHour < EndHour)
result = TimeCurrent() >= SessionStart && TimeCurrent() < SessionEnd;
else
if (StartHour > EndHour)
result = (TimeCurrent() >= SessionStart && TimeHour(TimeCurrent()) < 24) || (TimeHour(TimeCurrent()) >= 0 && TimeCurrent() < SessionEnd);
return(result);
}
......................
then added TimeCondition() to the Buy Sell
if (Buy_1 < Buy_2 && TimeCondition())
{
Order = SIGNAL_BUY;
}
.....................
Now I am trying to code this .........yet it is not working...........help appreciated
if(!(TimeCurrent()>=StartHour && TimeCurrent()<=EndHour))
{
Comment("Non-Trading Hours!");
return(0);
}
else{
if(Show_Settings==true) PrintDetails();
else Comment("");
return(0);
}
}
bool TimeCondition()
{
bool result = false;
datetime SessionStart = StrToTime(StartHour+":"+StartMinute);
datetime SessionEnd = StrToTime(EndHour+":"+EndMinute);
if (StartHour < EndHour)
result = TimeCurrent() >= SessionStart && TimeCurrent() < SessionEnd;
else
if (StartHour > EndHour)
result = (TimeCurrent() >= SessionStart && TimeHour(TimeCurrent()) < 24) || (TimeHour(TimeCurrent()) >= 0 && TimeCurrent() < SessionEnd);
return(result);
}
......................
then added TimeCondition() to the Buy Sell
if (Buy_1 < Buy_2 && TimeCondition())
{
Order = SIGNAL_BUY;
}
.....................
Now I am trying to code this .........yet it is not working...........help appreciated
if(!(TimeCurrent()>=StartHour && TimeCurrent()<=EndHour))
{
Comment("Non-Trading Hours!");
return(0);
}
else{
if(Show_Settings==true) PrintDetails();
else Comment("");
return(0);
}
}