From Datetime value get uint or ulong number of seconds elapsed since January 01 1970, and vice versa.
You can get the low part of time value.
datetime t;
uint my_t=(uint)t;
Why do you need to save up the variable space so badly? Space optimization of the EAs/Indicators is the last thing having to do with success in Forex.
mql5:
You can get the low part of time value.
datetime t;
UINT my_t=(UINT)t;
Could you please give me a fully working example code?You can get the low part of time value.
datetime t;
UINT my_t=(UINT)t;
enivid:
Why do you need to save up the variable space so badly? Space optimization of the EAs/Indicators is the last thing having to do with success in Forex.
That's because I'm doing some mass backtesting using scripts. This scripts are recording on files the time of each virtual opened trade and closed trade, which at the end of the calculation are hundreds of thousands.
Why do you need to save up the variable space so badly? Space optimization of the EAs/Indicators is the last thing having to do with success in Forex.
claudio:
Could you please give me a fully working example code?That's because I'm doing some mass backtesting using scripts. This scripts are recording on files the time of each virtual opened trade and closed trade, which at the end of the calculation are hundreds of thousands.
logical design is far better than backtesting from past. Use demo account to test forward ( future is only ahead man)
Could you please give me a fully working example code?That's because I'm doing some mass backtesting using scripts. This scripts are recording on files the time of each virtual opened trade and closed trade, which at the end of the calculation are hundreds of thousands.
Documentation on MQL5: Standard Constants, Enumerations and Structures / Environment State / Account Properties
- www.mql5.com
Standard Constants, Enumerations and Structures / Environment State / Account Properties - Documentation on MQL5
ok I figured !
This example code works great
Thanks a lot "Mql5"
datetime TimeArray[1]; CopyTime(_Symbol,PERIOD_M1,0,1,TimeArray); datetime t=TimeArray[0]; uint my_t=(uint)t; Print(t," is equal to ",my_t," seconds after January 01, 1970"); // Creating the opposite example my_t-=3600; // 3600 seconds=1 hour JUST MAKING A DIFFERENT NUMBER t=(datetime)my_t; Print(my_t," seconds after January 01, 1970 are equal to ",t);What is this type of operation?
my_t=(uint)t
Could you please point it out on the MQL5 reference.
You light up my day, Thankssssss ;-)

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
We all know that the Datetime type is actually storing the integer number of seconds elapsed since January 01 1970, but it seems there is no function to get access to this particular value, or to get a Datetime value given the number of seconds elapsed since January 01 1970.
Do you know any good way of doing this?
My intention is to store Datetime values as uint type values to save twice memory space.
This would allow me to store Datetime values until year 2106!
I kind of promised myself that if I won’t be a rich forex trader by that year, I will switch to the pizza delivery business.
I don’t understand why MQL5 is going as far as 31 December 3000, making the datetime type as bulky as 8 bytes (rather than the 4 bytes of the uint type)