EA places trades on strategy tester but fails to place on live? - page 2

 

Probably this

if(Hour()==X && Minute()==Y && Seconds()==Z)

 If there is no tick for that second, or the tick is missed, the code will not be executed

 
GumRai:

Probably this

 If there is no tick for that second, or the tick is missed, the code will not be executed

Yes. Specific time is a no go. Must use something else.
 
GumRai:

Probably this

 If there is no tick for that second, or the tick is missed, the code will not be executed

deysmacro:
Yes. Specific time is a no go. Must use something else.
Okay cool. Thanks!
 
deysmacro:
Yes. Specific time is a no go. Must use something else.
Do you have any suggestions by any chance? I did some pondering, and I don't know the code, but would there be a way to make it trade on a certain candle from the 00:00 candle or anything like that?
 
if(Hour()==X && Minute()==Y)

Use || to expand the coverage for the minute

 
deysmacro:

Use || to expand the coverage for the minute

Okay cool, so for example:
if(Hour()==X && Minute()==Y || Minute()==Y+1) 
 
if(Hour()==X && (Minute()==Y || Minute()==Y+1)) 

You need to use ( ) so that it would execute properly. Applies to others when necessary.

 
deysmacro:

You need to use ( ) so that it would execute properly. Applies to others when necessary.

Fantastic! Thanks for your help!
 
if(Hour()==X && (Minute()==Y || Minute()==Y+1)) 

Still has the same problem. What if there are no ticks during those two minutes, such as the Asian session.

static int HR2400 = PERIOD_D1 * 60; // 86400 = 24 * 3600
int      TimeOfDay(datetime when=0){
   return (when == 0 ? TimeCurrent() : when) % HR2400 );            }
datetime DateOfDay(datetime when=0){
   return (when == 0 ? TimeCurrent() : when) - TimeOfDay(when) );   }
datetime Tomorrow( datetime when=0){
   return DateOfDay(when == 0 ? TimeCurrent() : when) + HR2400);    }
datetime Yesterday(datetime when=0){   DownloadHistory(PERIOD_D1);
   datetime today = DateOfDay(when == 0 ? TimeCurrent() : when);
   int      iD1   = iBarShift(NULL, PERIOD_D1,  today - 1);
   return iTime(NULL, PERIOD_D1, iD1); }
:
static datetime when=0;                        // Remember
when = DateOfDay() + X*3600 + Y*60;            // When
:
if(when != 0 && TimeCurrent() > when){ 
   when=0;                                     // once only.
 
WHRoeder:

Still has the same problem. What if there are no ticks during those two minutes, such as the Asian session.


I used this, just to ensure that it does place (trading 5M):

if(Hour()==X && (Minute()==Y || Minute()==Y+1 || Minute()==Y+2 || Minute()==Y+3 || Minute()==Y+4) && (Seconds()==0 || Seconds()==10 || Seconds()==20 || Seconds()==30 || Seconds()==40 || Seconds()==50))

 A tick seems to come in in one of these.

Thanks for your help! 

Reason: