why this should be a logic issiu i dont understand
i tried out
Print(TimeLocal()," + ", TimeTradeServer());
and its come exactly the same time.
so if i understand you right, its better to run the code in OnTime, with a 1 second timer it should be work right?
that i know, its dont anything bordering me right now, bcs its only the test for the conversation
You asked why this should be a logic issue if TimeLocal() and TimeTradeServer() give you the same value, and if it is better to run the code in OnTimer() with a one-second timer so it works more reliably.
The times are equal in your setup because your broker's server is using the same timezone as your PC. That will not always be the case. On another broker, or if the server changes its configuration, there will be an offset. This is why the conversion logic is necessary if you want your code to work everywhere.
Running the code in OnTimer() with EventSetTimer(1) is indeed the correct approach. Tick arrival is never aligned exactly to the second, which is why you see trades executing a few seconds earlier. With a one-second timer you avoid that drift. In addition you still need to separate open and close logic and add a once per day control, otherwise duplicates and inconsistent results will appear even with the timer.
why this should be a logic issiu i dont understand
i tried out
and its come exactly the same time.
Of course they are both using the local time as a reference.
Your issue is because there is a small shift in your local time (some seconds), you need to round your GMTOff to integer hour then multiply by 3600 to get rid of these lack of synchronization between your local time and server time.
Strictly speaking it should be rounded to "quarter" of hour if you want universal code, but hour rounding will be sufficient in your case.r issue is becaus
Of course they are both using the local time as a reference.
Your issue is because there is a small shift in your local time (some seconds), you need to round your GMTOff to integer hour then multiply by 3600 to get rid of these lack of synchronization between your local time and server time.
Strictly speaking it should be rounded to "quarter" of hour if you want universal code, but hour rounding will be sufficient in your case.means, when i round 09:15:00 or 09:30:00 it would be ok, but 09:35 couses this fault?
I didn't explain well sorry.
You local time and the server time are not synchronized (independently of any GMT/DST shift). For example, supposing the same GMT/DST on both side, your local time can be 18:20:00 but the server time is 18:19:58 !
datetime Start=0; Startzeit = ..18:20..; datetime nowGMT = TimeGMT(); // aktuelle GMT-Zeit int GMTOff = 0; // then you set Start Start = 18:20:00
So your condition to trade is true BUT the server time is 18:19:58
TimeTraderServer() is based on LOCAL time (+-GMT/DST). You need to check TimeCurrent().
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
hello,
i have some troubles with the trade time, i have written an expert to convert the trade time to i time i want to trade
here as example the settings
that works with the conversation
but in the trade history i find following, its always couple of seconds before the time
that it makes 2 trade its ok, i dont have the code done so fare
the one hour difference is from the trade server, the time conversation is, that i can enter the local time
anyone an idea or is this a broker issiu on the trade server?
regards