Hi everyone, I have a problem with my mt4 EA.
Basically it’s designed to trade within a time window set by the user at startup (extern).
extern dateime StartTime;
extern datetime EndTime;
bool IsTradingTime = false;
//-----------------------------------
if (TimeLocal() >= StartTime && TimeLocal() < EndTime) IsTradingTime = true;
else IsTradingTime = false;
if I don’t initialize my datetime variables they will be set by default to 0 (therefore 1/1/1970) and to set the correct day I have to click on “today” and do it manually.
Here comes the question: is there any method to automatically change the value of Start and End time to current date instead of having 1970.01.01?
I already tried setting extern datetime StartTime = TimeLocal() but it doesn’t work since the EA has to be initialized to read TimeLocal(), therefore it happens after EA’s inputs are prompted.
Many thanks in advance to those who will help.
Solution:
initialize variables as
extern datetime StartTime = D;
extern datetime EndTime = D;