IntraTrade:
u can't change the platform or brokers time but u can synchronize your system time to the brokers time automatically let's say every hour or so
How can I change plattform/broker-time in MT4 so it will be syncronised to "system time"?
qjol:
u can't change the platform or brokers time but u can synchronize your system time to the brokers time automatically let's say every hour or so
u can't change the platform or brokers time but u can synchronize your system time to the brokers time automatically let's say every hour or so
Is there a function to synchronize system-time to "brokers time automatically"?
I can do it by a workaround, but is there a simple solution, please let me know!!!
I changed your code, so I get my own timezone with the MT4 time. I will load this as an EA and I put one hour "Sleep" in an everlasting loop. I haven´t tried this yet. I will attach my EA on some odd forex symbol...
I´m a super newbie with a week of experience of MT4, so will this work?
//+------------------------------------------------------------------+ //| SyncCompClockToServer.mq4 | //| Copyright © 2010, nadav. | //+------------------------------------------------------------------+ #property copyright "Copyright © 2010, NADAV." //+------------------------------------------------------------------+ //| script program start function | //+------------------------------------------------------------------+ #import "shell32.dll" int ShellExecuteA(int hwnd,string Operation,string File,string Parameters,string Directory,int ShowCmd); int start(){ datetime BrokerTime, MyTime; string ServerTime, ServerDate, mm, dd, yy; double MyTimeZone = -2; //--- Change MyTimezone to you local, in my case -2 int StayWhile = 1; while (StayWhile == 1){ //--- Updates once every hour Sleep(60*60*1000); RefreshRates(); //---- Calculation BrokerTime = TimeCurrent(); MyTime = BrokerTime - (MyTimeZone)*3600; ServerTime = TimeToStr((TimeHour(MyTime)/24)+(TimeMinute(MyTime)/(24*60))+(TimeSeconds(MyTime)/(24*60*60))); ServerDate = DoubleToStr(TimeYear(MyTime),0) + "." + DoubleToStr(TimeMonth(MyTime),0) + "." + DoubleToStr(TimeDay(MyTime),0); //string ServerTime = TimeToStr(TimeCurrent(),TIME_SECONDS); //string ServerDate = TimeToStr(TimeCurrent(),TIME_DATE); mm = StringSubstr(ServerDate,5,2); dd = StringSubstr(ServerDate,8,2); yy = StringSubstr(ServerDate,2,2); ShellExecuteA(0, "Open", "cmd.exe", "/c date" + " " + mm + "-" + dd + "-" + yy, "", 1); ShellExecuteA(0, "Open", "cmd.exe", "/c time" + " " + ServerTime, "", 1); } return(0); } //+------------------------------------------------------------------+
IntraTrade:
I almost forgot... Thank You!
Clean up!I almost forgot... Thank You!
//+------------------------------------------------------------------+ //| SyncCompClockToServer.mq4 | //| Copyright © 2010, nadav. | //+------------------------------------------------------------------+ #property copyright "Copyright © 2010, NADAV." //+------------------------------------------------------------------+ //| script program start function | //+------------------------------------------------------------------+ #import "shell32.dll" int ShellExecuteA(int hwnd,string Operation,string File,string Parameters,string Directory,int ShowCmd); int start(){ datetime MyTime; string ServerTime; double MyTimeZone = -2; //--- Change MyTimezone to you local, in my case -2 int StayWhile = 1; while (StayWhile == 1){ //--- Updates every hour Sleep(60*60*1000); //---- Calculation MyTime = TimeCurrent() - (MyTimeZone)*3600; ServerTime = TimeToStr((TimeHour(MyTime)/24)+(TimeMinute(MyTime)/(24*60))+(TimeSeconds(MyTime)/(24*60*60))); ShellExecuteA(0, "Open", "cmd.exe", "/c date" + " " + DoubleToStr(TimeMonth(MyTime),0) + "-" + DoubleToStr(TimeDay(MyTime),0) + "-" + DoubleToStr(TimeYear(MyTime),0), "", 1); ShellExecuteA(0, "Open", "cmd.exe", "/c time" + " " + ServerTime, "", 1); } return(0); }
//+------------------------------------------------------------------+ //| SyncCompClockToServer.mq4 | //| Copyright © 2010, nadav. | //+------------------------------------------------------------------+ #property copyright "Copyright © 2010, NADAV." //+------------------------------------------------------------------+ //| script program start function | //+------------------------------------------------------------------+ #import "shell32.dll" int ShellExecuteA(int hwnd,string Operation,string File,string Parameters,string Directory,int ShowCmd); int start(){ datetime MyTime; string ServerTime, ServerDate; double MyTimeZone = -2; //--- Change MyTimezone to your local, in my case -2 int StayWhile = 1; while (StayWhile == 1){ //--- Updates every hour RefreshRates(); //---- Calculation MyTime = TimeCurrent() - (MyTimeZone)*3600; ServerDate = DoubleToStr(TimeYear(MyTime),0) + "-" + DoubleToStr(TimeMonth(MyTime),0) + "-" + DoubleToStr(TimeDay(MyTime),0); ServerTime = DoubleToStr(TimeHour(MyTime),0) + ":" + DoubleToStr(TimeMinute(MyTime),0) + ":" + DoubleToStr(TimeSeconds(MyTime),0); ShellExecuteA(0, "Open", "cmd.exe", "/c date" + " " + ServerDate, "", 1); ShellExecuteA(0, "Open", "cmd.exe", "/c time" + " " + ServerTime, "", 1); Sleep(600000); } return(0); }
The script above is tested and working:
In Sweden the date is yyyt-mm-dd, you may have to change this...
that's y i use StringSubstr() (yy mm dd or whatever u need) to be able to change quickly
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 can I change plattform/broker-time in MT4 so it will be syncronised to "system time"?
I know how to change time to local time (I add -2h), so that I get my local time in my scripts. And I could change all to MT4-time, it would work perfekt, but my external algo runs on system time...
Background:
If I compare my system clock right now it could be 3 seconds ahead. Tomorrow I could be 3 seconds behind.
Because I export all data on second "00" (last 1 min period), to a SQL-server it is important that I get the whole last-minute data.
I run an external algo on system time, thats why I want to export data in systemtime.
Poor solution:
A workaround could be that I export MetaTrader-time through something, maybe a loop that writes to a textfile every second (this feature could also work as a check for an external Watchdog) and I change my algo to MetaTrader-time.
A bad solution would be to make a DDE-server, because then I have to wait for a tick, to get the time.
Any solution?