You should consult the documentation when in doubt: https://docs.mql4.com/basis/types/integer/datetime
Datetime Type
The datetime type is intended for storing the date and time as the number of seconds elapsed since January 01, 1970. This type occupies 8 bytes of memory.
So, first convert your "day" into "seconds" then add them:
#define _DAYSECONDS_ 86400; // 1day = 24hr * 60min * 60sec = 86400sec input int days = 10; // use "input" instead of "extern" to prevent changes to variable within code execution datetime d1 = D'20.12.2016', dnew = d1 + days * _DAYSECONDS_;
thanks a lot dear Fernando
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
I want to declare an external integer variable for day and add it to a datetime variable, Is it possible?
I need some code Like this, to get for example 10 days from an external variable an add it to my datetime variable.
Should I first convert days to millisecond then add to datetime? how can I do that?
just help me how can I add some days to a datetime variable...