Download MetaTrader 5

Scripts: Pausing execution of EA until certain time has passed

To add comments, please log in or register
MetaQuotes Software Corp.
Moderator
184486
MetaQuotes Software Corp.  

Pausing execution of EA until certain time has passed:

This code will get the current time , wait until a certain amount of Seconds has passed and then continue processing.

Author: buju

whroeder1
15346
whroeder1  

Or a simple static variable, much easier:

start(){
  static datetime Time.update;			// No open order,
  if (CurTime() < Time.update)	return(0);	// Can't trade yet.
//...
  if (!Compute()) {		                // Not good enough
    Time.update = CurTime() + X*60;	        // continue waiting X minutes.
  //Time.update = Time[0] + Period()*60;	// continue waiting for next bar.
    //...
MQL4 Comments
16319
MQL4 Comments  

I think this might be a starting point for what I am Looking for. I want to add entry and exit times to an EA. Example would be I only want to trade the EURUSD overnight from 12am EST to 6am and or for the Opening of our US Stock Market. As of right now the EA I have been testing tests 24 hrs of trading. Would appreciate any help on this. I am just learning how to code etc.


Thanks,

Jim Contant

"Jims Trading Machine"

To add comments, please log in or register