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
How to Calculate with date and times?
On several places there are comments like the following (https://www.mql5.com/en/forum/688):
datetime t;
MqlDateTime mdt;
TimeToStruct(t,mdt);
mdt.day += 45;
//or mdt.day = 50; //50 days from the beginning of the month
//or mdt.hour += 134; //134 hours in the future
//or mdt.hour = 1000; //1000 hours from the beginning of the day
This works but gives incorrect results. example:
mdt.day -= 50 gives an negative day and not a day one ore two month in the past.
What is MqlDateTime useful for if not for calculations?
and how do you calculate valid dates?
Attached is a indicator that shows the incorrect behavior of the above method
regards and thanks for your help
Daniel