Download MetaTrader 5

How to initialize extern datetime with current time?

To add comments, please log in or register
Do you have idle PCs? Connect them to MQL5 Cloud Network and earn money!
Wemerson Guimaraes
560
Wemerson Guimaraes 2015.07.30 20:27 

Hy guys...

There is a way to initialize an external datetime variable with the current time ?

 

I'm try something like this: 

extern datetime fundamental = TimeCurrent();

 

But returns me the following error: 'TimeCurrent' - constant expected

 

I need to show the current time, not  1790.01.01 00:00

Keith Watford
Moderator
9620
Keith Watford 2015.07.30 21:33  

Declare the variable Globally, then give it the value in init.

Be aware though, if the EA/indicator is attached to a chart when starting MT4, TimeCurrent may be wrong.

Wemerson Guimaraes
560
Wemerson Guimaraes 2015.07.30 22:00  
GumRai:

Declare the variable Globally, then give it the value in init.

Be aware though, if the EA/indicator is attached to a chart when starting MT4, TimeCurrent may be wrong.

I need it just to show an actual date on Indicator properties window, not oldest date... run it as you say still show 1970.01.01 00:00 on the properties page. See:

 

Keith Watford
Moderator
9620
Keith Watford 2015.07.31 00:15  

Sorry, I misunderstood. You want to be able to change it?

I don't think it's possible to have it default to TimeCurrent() 

JD4
1101
JD4 2015.07.31 01:14  
wemersonrv:

I need to show the current time, not  1790.01.01 00:00

Wow, I didn't know they had the capacity to count time with computers back in 1790.
Wemerson Guimaraes
560
Wemerson Guimaraes 2015.07.31 01:28  
I just need to show the TODAY time on properties... it's boring select the right date, because every time the indicator is added on graphic, it's shows 1970 date... not today
Vasyl Nosal
18537
Vasyl Nosal 2015.07.31 05:50  
wemersonrv:
I just need to show the TODAY time on properties... it's boring select the right date, because every time the indicator is added on graphic, it's shows 1970 date... not today
Select for what?
Keith Watford
Moderator
9620
Keith Watford 2015.07.31 11:54  
wemersonrv:
I just need to show the TODAY time on properties... it's boring select the right date, because every time the indicator is added on graphic, it's shows 1970 date... not today
Explain why it is so important to have today's date and someone may be able to help you with a work_around
Wemerson Guimaraes
560
Wemerson Guimaraes 2015.07.31 16:19  
GumRai:
Explain why it is so important to have today's date and someone may be able to help you with a work_around

As an user, i hate it... just imagine 10 datetime fields that you need to change all of them manually from 1970 to now... 

 

As an developer, Thinking in a good user experience, i think if i solve this issue will be a good idea to make the users more happy

 

 

Sorry for my bad english! Using google translator! 

whroeder1
14480
whroeder1 2015.07.31 18:03  
wemersonrv: I just need to show the TODAY time on properties... it's boring select the right date, because every time the indicator is added on graphic, it's shows 1970 date... not today
extern string begin = "TODAY"; // YYYY.MM.DD [HH:MM]

datetime when = (date == "TODAY") TimeCurrent() : StringToTime(begin);
Wemerson Guimaraes
560
Wemerson Guimaraes 2015.08.01 18:32  
WHRoeder:

Not works like that, because TODAY is only an example... user can select  any datetime, starting from NOW to future dates... 
12
To add comments, please log in or register