Use this data type instead, much less error-prone and easier to use overall:
https://docs.mql4.com/basis/types/datetime
.
Jon
Thank you for your answers I will change my code tonight.
Can I ask you how you would have done to execute 2 actions at different hours/time ?
Which computer logica do you use to handle such things ?
int start(){
if(TimeHour(TimeCurrent()) == 9 && TimeMinute(TimeCurrent())) == 0) Print("Execution Time1");
if(TimeHour(TimeCurrent()) == 9 && TimeMinute(TimeCurrent())) == 5) Print("Execution Time2");
return(0);
}
if(TimeHour(TimeCurrent()) == 9 && TimeMinute(TimeCurrent())) == 0) Print("Execution Time1");
Tryprogmq4's original code (with CB's amendment) has the advantage of not assuming that there will be a tick between 09:00:00 and 09:00:59. It looks as though Tryprogmq4 wants an alert at 09:00/09:05 or the first tick after that. There are obviously plenty of symbols and times of day when you're not guaranteed to see a tick within a particular minute.
int start(){
if(TimeHour(TimeCurrent()) == 9 && TimeMinute(TimeCurrent())) == 0) Print("Execution Time1");
if(TimeHour(TimeCurrent()) == 9 && TimeMinute(TimeCurrent())) == 5) Print("Execution Time2");
return(0);
}
Hi Phy,
I do not know how to code, I have an idea how to code EA which is will open position every 4 hours. I am still learning how to code. Please.
thanks
axadnan

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Good morning,
I'm quite new in MQL4 programming so I only try a very simple program but it is not working perfectly.
Let's explain what I would like :
At 9:00 print a message
At 9:05 print another message
Result :
If I launch the expert advisor at 8:55 :
at 9:00 the expected message is written
at 9:05 nothing appens. I suppose there is something wrong with the "if / else".
What's wrong with my code ? Why is there only one action executed at 9:00 and nothing at 9:05 ?
Any help would be appreciated.