TimeLocal( | ) |
If you don't like the values in seconds then convert them
TimeToStr(TimeLocal(),TIME_SECONDS)
You should really search around within the MQL help files, all this stuff is nicely documented there for your benefit.
The nature of an EA is mostly process the price data as it is sent out from your broker. The EA (unless in a continuous refresh data loop) can not do anthing until it has data to work with.
This is why TimeLocal gives you your local PC time when ever new price data package (a tick) arrives.
TimeLocal( | ) |
If you don't like the values in seconds then convert them
TimeToStr(TimeLocal(),TIME_SECONDS)
You should really search around within the MQL help files, all this stuff is nicely documented there for your benefit.
phillip,
TimeLocal() is not my PC time which I'm looking for.
Thanks for the tip, I will try out the search to see if it is any good.
Bill H.
The nature of an EA is mostly process the price data as it is sent out from your broker. The EA (unless in a continuous refresh data loop) can not do anthing until it has data to work with.
This is why TimeLocal gives you your local PC time when ever new price data package (a tick) arrives.
Ickyrus,
TimeLocal() is not my PC time which I'm looking for, it is the data tick time, check it out.
Bill H.
https://docs.mql4.com/dateandtime/TimeLocal :
"datetime TimeLocal()
Returns local computer time as number of seconds elapsed from 00:00 January 1, 1970.
Note: At the testing, local time is modelled and is the same as the modelled last known server time. "
The following code sample displays in the chart the local PC time independently of incoming ticks because works in cycle mode.
//< This is EA : Compile and run in folder "/experts" >
int start()
{
static int iClockPeriod = 1000 ;
static int iTimeStamp ;
static int iRunTime ;
while ( ! IsStopped () )
{
iTimeStamp = GetTickCount () ;
Comment ( "Day of week " , DayOfWeek () , "\n" ,
"PC time " , TimeToStr ( TimeLocal () , TIME_SECONDS ) , "\n" ,
"Server time " , TimeToStr ( TimeCurrent () , TIME_SECONDS ) ) ;
iRunTime = GetTickCount () - iTimeStamp ;
Sleep ( iClockPeriod - iRunTime ) ;
}
}
//</This is EA : Compile and run in folder "/experts" >
What is your PC's GMT shift? The PC time that the function is picking up could be affected by the Windows method of handling time, are you in EST or PST or GMT is the PC operating with Daylight Saving Shift?
This set of functions may help in solving your problems. https://www.mql5.com/en/code/7789
Remember we are not in front of your PC so we dont know without pictures or the ability to check your PC's windows setup all the things that can go wrong.
![MQL5 - Language of trade strategies built-in the MetaTrader 5 client terminal](https://c.mql5.com/i/registerlandings/logo-2.png)
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hi,
Anyone have a script to get the day and time from my PC for an EA? Maybe something to do with a DLL to Windows or a call to DOS.
I don't want to use the weird times I'm getting from Siberia or wherever the MetaTrader 4 is getting data ticks from and there date and times.
It seems all of the commands in MetaTrader 4 are using the data tick dates and times.
I also don't want seconds since January 1, 1970, that's just a stupid Microsoft idea with no forethought for years into the future.
I'm looking for a digit like 5 to represent Friday and 15:00 hours Eastern Time to close out any open orders.
TIA
Bill H.