MT4 time is number of seconds past sinse Jan 1, 1970, a special variable type datetime
is used, which is in fact a simple int
.
How to constuct time? Two simple ways: from string and from struct.
datetime time=StringToTime(StringFormat("%04d.%02d.%02d %02d:%02d",year,month,day,hour,minute));
Alternatively,
MqlDatetime dt;
dt.year=year;
dt.mon=month;
dt.day=day;
dt.hour=hour;
dt.min=minute;
datetime time=StructToTime(dt);
What time is available in MT4? Three types of time can be called:
current time of the broker (what you actually see on the chart and in the market window) is the default time, you can get it by calling TimeCurrent()
or iTime(_Symbol,PERIOD_M1,0)
;
GMT+0 can be achieved by TimeGMT()
; and
your local PC time can be achieved via TimeLocal()
function.
Which of them to use - it is up to you.
Placing order by time condition is similar to placing an order with other conditions.
if(condition)OrderSend(..);