EA starting-up times

 

Hello,


I have EA where I can define starting-up time:


start=XHour*3600+XMin*60;


but I need define more EA starts in day.

Something like this:

start=1Hour*3600+1Min*60;

or

start=2Hour*3600+2Min*60;

or

start=3Hour*3600+3Min*60;


can somebody help me with coding?


Thank you.

 

Something like this?

extern int StartHour=5;

extern int EndHour=15;

init()
{


}

start()
{


// ================= Do stuff every tick START ==================

   // Evaluate for Close of open trades






  // Evaluate for move of Trailing Stops





// ================= Do stuff every tick END ==================



// ================= Do stuff between limit hours START ==================


  if(Hour() < StartHour) return(0); // Too early

  if(Hour() > EndHour) return(0); // Too late


  // If got here you are in trading window so evaluate for Open 


  // Count current open trades to avoid orders ramping up




  // If count OK check for Open




// ================= Do stuff between limit hours END ==================



return (0);
}

Good Luck

-BB-

 
BarrowBoy:

Something like this?

Good Luck

-BB-

Hi,


I found this script, but I need something else.

I want start EA at exact time only.

i.e.

Start EA at 9:00 am....11:00am....15:00pm..etc

 
bebeka wrote >>

Hi,

I found this script, but I need something else.

I want start EA at exact time only.

i.e.

Start EA at 9:00 am....11:00am....15:00pm..etc

if(Hour() == 7 || Hour()==9) ... maybe?

 
EADeveloper:

if(Hour() == 7 || Hour()==9) ... maybe?

Its look good...

can you add Minutes to code please....?


Thank you!

 

If you are going for Time to the minute - keep in mind you may not get a tick during that minute - so the EA wont know that time is occurring

Ticks are not time, simply a change occurring in MarketInfo() and as ticks drive EA's, you have to allow for that

If you must use minutes, make sure its at least a range of minutes

-BB-

 
BarrowBoy wrote >>

If you are going for Time to the minute - keep in mind you may not get a tick during that minute - so the EA wont know that time is occurring

Ticks are not time, simply a change occurring in MarketInfo() and as ticks drive EA's, you have to allow for that

If you must use minutes, make sure its at least a range of minutes

-BB-

For a daily range, I do it like this:

extern int OpenHour;

extern int OpenMinute;

extern int CloseHour;

extern int CloseMinute;

start () {

...

if (TradeDesk) {...}

...

}


bool TradeDesk(int OpenHour, int OpenMinute, int CloseHour, int CloseMinute) {
bool DeskOpen=false;
if ((Hour()>OpenHour && Hour()<CloseHour) || (Hour()==OpenHour && Minute()>=OpenMinute) || (Hour()==CloseHour && Minute()<CloseMinute)) DeskOpen=true;
return (DeskOpen);
}

 

jingodelcuyo:



Its still time range! I need start-up EA at exact time.





It is possible start EA by server or client PC time??? Not by tick?


Thank you.









 
bebeka wrote >>

jingodelcuyo:



Its still time range! I need start-up EA at exact time.





It is possible start EA by server or client PC time??? Not by tick?


Thank you.









You can use

datetime TimeLocal( )

 
bebeka:

jingodelcuyo:



Its still time range! I need start-up EA at exact time.





It is possible start EA by server or client PC time??? Not by tick?


Thank you.









Hi bebeka,


<quote : I want start EA at exact time only. i.e. Start EA at 9:00 am....11:00am....15:00pm..etc>


in case you're still seeing this,

How 'exact' do you need it to start.. Isn't an interval of 60 seconds on M1 close enough? A tick will come at least once every bar (I've heard of a missing bar chart b4, but never seen it myself)... so jingodelcuyo's code defining the time-range check can be narrowed to one minute (or two) and checking at first tick (learned from BarrowBoy) will be 'immediate' enough IMHO..

I've use it this way for expiry (trick from codersguru), it's triggered right on the minute:


bool ea_start(datetime time_start, datetime time_start_local)
{
time_start= D'2009.03.20 09:00'; time_start_local=D'........' ; // Local time must account for broker time difference

if ( TimeCurrent() == time_start || TImeLocal() == time_start_local && Volume[0]==1) return(true);

else return (false);

}

if(ea_start) {run your ea....}


good luck :)

cameo

Reason: