Download MetaTrader 5

How to initialize extern datetime with current time?

To add comments, please log in or register
Wemerson Guimaraes
627
Wemerson Guimaraes  

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
10544
Keith Watford  

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
627
Wemerson Guimaraes  
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
10544
Keith Watford  

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
1100
JD4  
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
627
Wemerson Guimaraes  
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
19496
Vasyl Nosal  
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
10544
Keith Watford  
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
627
Wemerson Guimaraes  
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
16496
whroeder1  
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
627
Wemerson Guimaraes  
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