Download MetaTrader 5

How to get today date ? , even backtest history still know today date. - page 2

To add comments, please log in or register
Stanislav Korotky
21498
Stanislav Korotky  
Fernando Carreiro:

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:

Siwakon Poonsawat:

l want to get real today date ,like check from broker.

So, I suppose he wants server time.

Fernando Carreiro
2837
Fernando Carreiro  
Stanislav Korotky: I mean you can get local time from the tester as well, and there's no need to deal with DLLs. But OP wrote:

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!

Stanislav Korotky
21498
Stanislav Korotky  
Fernando Carreiro:

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:

/**
 * Get current local time, UTC (GMT zone), according to PC clock
 */
datetime getCurrentUTC()
{
  string tmpgv = "_UTC_TMP_GLOBAL_VARIABLE_";
  datetime now = GlobalVariableSet(tmpgv, 0);
  GlobalVariableDel(tmpgv);
  return now;
}

int OnInit()
{
  Print("Started at ", TimeToString(getCurrentUTC()));
  return INIT_SUCCEEDED;
}
Fernando Carreiro
2837
Fernando Carreiro  
Stanislav Korotky: To get local time in the tester one can use the following workaround:

Interesting and unconventional way to do it, but quite imaginative! Thanks!

12
To add comments, please log in or register