time specific code

 

hi,

  does anyone know how to enter trade at specific time? Thanks in advance. 

 
thezen:

hi,

  does anyone know how to enter trade at specific time? Thanks in advance. 

Hi thezen,

I think there's plenty of that in the forum if you willing to search. This code below is just an example

input int Open_Hour=3;
input int Open_Minute=7;
input bool Use_Broker_Time = false;
//+------------------------------------------------------------------+
//|  program start function                                          |
//+------------------------------------------------------------------+
void OnStart()
  {
  datetime    open_time;
  MqlDateTime struc_time;
  
  if (Use_Broker_Time == true)
    open_time = TimeCurrent();
    else
    open_time = TimeLocal();
    
  TimeToStruct(open_time,struc_time);
  
  if (struc_time.hour >= Open_Hour && struc_time.min >= Open_Minute)
    {
    // open business here
    
    }
  }

 

 
onewithzachy:

Hi thezen,

I think there's plenty of that in the forum if you willing to search. This code below is just an example

 

Thanks onewithzachy! Pardon for my ignorance, how could I open a position within the bracket?  Thanks for helping a newbie!
 

of course you can but i think you should also restrict the time from the upside

 
thezen 2012.09.14 07:29 
Thanks onewithzachy! Pardon for my ignorance, how could I open a position within the bracket?  Thanks for helping a newbie!

Hi thezen, 

I don't understand your question there ("how could I open a position within the bracket? "), of course you could. However if you meant some open position code, there's a lot example around.

Like this script to open buy and to open sell (click that) and my previous code https://www.mql5.com/en/forum/6666#comment_192901 please read the entire thread starting from there.

And you should set the upper time like onlysolo suggest. 

 

Reason: