
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
OP wants to get local time while using the Strategy Tester, hence why the Win32 API suggestion.
Obviously, when not using the Strategy Tester, but on a Live chart, you don't need to use the Win32 API.
I mean you can get local time from the tester as well, and there's no need to deal with DLLs. But OP wrote:
l want to get real today date ,like check from broker.
So, I suppose he wants server time.
So, I suppose he wants server time.
If you see is posted images, you see that he wants the real local time, not the server time.
However, you say one can get the local time without Win32 API even in the Strategy Tester, but you still have not stated how to do that!
If you see is posted images, you see that he wants the real local time, not the server time.
However, you say one can get the local time without Win32 API even in the Strategy Tester, but you still have not stated how to do that!
As I quoted above, OP wants broker time not local time.
To get local time in the tester one can use the following workaround:
Interesting and unconventional way to do it, but quite imaginative! Thanks!
Sorry, Stanislav, but using your getCurrentUTC() method in the Strategy Tester I still get the latest simulated date and not the current date of the PC.
Can anyone confirm this is working for him/her?
Sorry, Stanislav, but using your getCurrentUTC() method in the Strategy Tester I still get the latest simulated date and not the current date of the PC.
Can anyone confirm this is working for him/her?
My computer time was 11:56 today (2019.10.19), Stanislav code returned :
2019.10.19 11:56:07.884 2019.01.21 00:00:00 215383 EURUSD,M5: Started at 2019.10.19 15:56
My time zone is GMT-4 currently, so it's current GMT time as announced (but certainly not "latest simulate date" as you stated). Using TimeGMTOffset() you can easily get current local time.
Or alternatively :
Ok, I've run the method from @Stanislav Korotky's, the variation suggested by @Alain Verleyen which includes the TimeGMTOffset() method and the file-operation method:
In live chart I obtain the following times:
In Strategy Tester / backtesting, starting the simulation from 01.01.2019, I obtain these times:
For those of us who need the actual time even during backtesting (e.g. because the VIX symbol from January 2019 is no more available), only the file operation delivers the current system time.
Cheers!
Ok, I've run the method from @Stanislav Korotky's, the variation suggested by @Alain Verleyen which includes the TimeGMTOffset() method and the file-operation method:
In live chart I obtain the following times:
In Strategy Tester / backtesting, starting the simulation from 01.01.2019, I obtain these times:
For those of us who need the actual time even during backtesting (e.g. because the VIX symbol from January 2019 is no more available), only the file operation delivers the current system time.
Cheers!
1° Are you posting MT5 results on the MT4 forum ? Please never do that, you are misleading readers. MT5 results are different (as you said only File approach is working).
2° Your code has a bug :
3° As I already said, BOTH approach are working with MT4.
Your code (fixed) on a live chart :
2019.11.16 15:50:55.592 215383_18 EURUSD,H1: Time obtained from file operation: 2019.11.16 15:50
2019.11.16 15:50:55.592 215383_18 EURUSD,H1: Current UTC - GMT offset: 2019.11.16 15:50
2019.11.16 15:50:55.592 215383_18 EURUSD,H1: GMT offset: 18000
2019.11.16 15:50:55.592 215383_18 EURUSD,H1: Current UTC: 2019.11.16 20:50
On a backtest :
2019.11.16 15:51:50.511 2019.01.21 00:00:00 215383_18 EURUSD,M5: Current UTC - GMT offset: 2019.11.16 15:51
2019.11.16 15:51:50.511 2019.01.21 00:00:00 215383_18 EURUSD,M5: GMT offset: 18000
2019.11.16 15:51:50.511 2019.01.21 00:00:00 215383_18 EURUSD,M5: Current UTC: 2019.11.16 20:51