Ching Soon Lim: Hello, I have this code to get the GMT in second, it give warning that I convert from datatime to int, yes, I know that. How to get rid of the warning? Can someone please help?
Make an explicit typecast. However, please note that a "datetime" is equivalent to a "long" and not an "int".
So, only use "int" for a time difference and not an actual full date and time, or else you will suffer information loss.
int GetGMTinSec( void ) { return int( TimeTradeServer() - TimeGMT() ); };
Documentation on MQL5: Language Basics / Data Types / Typecasting
- www.mql5.com
Typecasting - Data Types - Language Basics - MQL5 Reference - Reference on algorithmic/automated trading language for MetaTrader 5
Ching Soon Lim:
Hello,
I have this code to get the GMT in second, it give warning that I convert from datatime to int, yes, I know that. How to get rid of the warning? Can someone please help?
Please note this code doesn't give you the "GMT in seconds". It gives you the broker server GMT time shift in seconds.
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
Hello,
I have this code to get the GMT in second, it give warning that I convert from datatime to int, yes, I know that. How to get rid of the warning? Can someone please help?