How can I set Hours and Minutes as input parameters and use it in my function.

 
Hy guys, new to mql5 and trying hard to understand it. Please help me with the following issue, I am trying to find a solution since 2 days without success. 

//Global paramters//
input parameter opentime = "12:00" (??)


//Get the local time//
   datetime time = TimeLocal();
   
//format the time and create a string//
string hoursAndMinutes = TimeToString(time,TIME_MINUTES);

if ((StringSubstr(hoursAndMinutes, 0, 5) == "07:00")

How can I replace 07:00 with an input parameter?

{//Buy Trade logic}//


Thank you very much!
 
tradefy: input parameter opentime = "12:00" (??)

When dealing with time, a lot of people use strings; they can not be optimized. Using (int) seconds or (double) hours and fraction can be inputs.

 
input string opentime = "12:00";
...
{
   datetime time = TimeLocal();
   string hoursAndMinutes = TimeToString(time,TIME_MINUTES);
   if (hoursAndMinutes == opentime)
    //do what you want here
}
...

simply define time as a string... Just you need to make sure entries are double digit format.(hh & mm)

 
William Roeder #:

When dealing with time, a lot of people use strings; they can not be optimized. Using (int) seconds or (double) hours and fraction can be inputs.

Strings are nice in settings. I use strings in the settings, and in OnInit I convert them to an integer format, which allows me to maintain high performance.