if(Timecurrent() == "0000.00.00. 00:00:00") { }
Or you can use MqlDate, like
MqlDate mydate;
int hours = mydate.hour;
Or something like that, look it in the documentation :)
Thanks... the problem is that the documentation is very bare on this subject and I am not an expert in C++. Also all the examples provided in MQL5 are regarding printing the time, not using it as a variable. I tried this:
if(datetime Timecurrent() == "2011.09.02 12:00:00") {GraphBuffer[i]=1; } else {GraphBuffer[i]=2;}
and the error was 'Timecurrent' - class type expected
However I don't want the effect for a specific day, I would like it for ANY day. Pleeeease somebody explain why I can't write:
if(datetime Timecurrent() == "12:00:00") {GraphBuffer[i]=1; } else {GraphBuffer[i]=2;}
Can I write something like this without the date?
Thanks... the problem is that the documentation is very bare on this subject and I am not an expert in C++. Also all the examples provided in MQL5 are regarding printing the time, not using it as a variable. I tried this:
if(datetime Timecurrent() == "2011.09.02 12:00:00") {GraphBuffer[i]=1; } else {GraphBuffer[i]=2;}
and the error was 'Timecurrent' - class type expected
However I don't want the effect for a specific day, I would like it for ANY day. Pleeeease somebody explain why I can't write:
if(datetime Timecurrent() == "12:00:00") {GraphBuffer[i]=1; } else {GraphBuffer[i]=2;}
Can I write something like this without the date
#define ONEDAY 86400
#define NOON 43200
if( TimeCurrent() % ONEDAY > NOON ) {
// do stuff when it is afternoon
}
else {
// do stuff when it is before noon
}
#define ONEDAY 86400
#define NOON 43200
if( TimeCurrent() % ONEDAY > NOON ) {
// do stuff when it is afternoon
}
else {
// do stuff when it is before noon
}
thanks very much fireflies, you are officially a life saver
excuse me what means the % sign? i cant find it in the documentation, thanks.
if( TimeCurrent() % ONEDAY > NOON ) {
excuse me what means the % sign? i cant find it in the documentation, thanks.
if( TimeCurrent() % ONEDAY > NOON ) {
You can find in the documentation. Language Basics-Operations and Expressions-Arithmetic Operations :
It means divisions reminder, example : minutes = time % 60;

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
hi,
I want to initiate an action dependent on tiem and it is driving me crazy... how do I do it?
For example:
if(time()=="1200") { x=1;}
Can somebody tell me the correct format please and save me from my headache?
Thanks in advance.