My Profitable EA works fine, but when i add a session flag it is not working ,what is the broblem ??

 

Hi code experts,

My problem is when i made my EA it's work fine but when i add a flag of American session time (to open positions at American market time only but it may close it at anytime) the EA stop working and didn't open any positions.

Really I tried to find where is the problem in the code, but i didn't find anything queer.

This is the EA of both the without & with flag.

Files:
macd_eav01.mq4  15 kb
 
This is with flag EA.
Files:
 
USA_S(Cur_time)//looks like you should use cur_hour instead of cur_time
 

Hi Fxcourt,

I tried using cur_hour but it failed and the same result, fails to open orders,

I really don't know where is the problem.

 

try this

 

Hi,


USA_S(TimeHour(TimeCurrent()))


and


bool USA_S (int time) // Cheking USA session
{

if (22.00 > time && time >= 14.00) // If in USA session
return(true); // Flag for USA session
else
return(false);
}




www.GetYourEA.com

 
bool USA_S (int time) // Cheking USA session
{
if (time < 22 && time >= 14) // If in USA session
return(true); // Flag for USA session
else
return(false);
}
 

Fxcourt & getyourea, great thanx to you .

Yes it maybe the problem of conditioning the time (hour or minute) must use one condition for each relational mark (<,>, <= or >=) .

I edited the code, and waiting the American session to test then i will return you the response here.


getyourea, the function TimeHour(TimeCurrent()) returns integer value, so the user-defined function USA_S() parameter (time) must be integer type not double then the code will be this bool USA_S (int time) // checking USA session

 
That's work, great thanx to you coders for help.
Reason: