MT5 Local Time Display - page 2

 
trademikenr #:

Can you tell me where to add this? I don't usually have an EA running . . . Many thanks!

Anywhere in the OnTick() function - if you just want a basic script run this:

//+------------------------------------------------------------------+
//|                                      352352-LocalTimeDisplay.mq5 |
//|                                  Copyright 2022, MetaQuotes Ltd. |
//|                                             https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2022, MetaQuotes Ltd."
#property link      "https://www.mql5.com"
#property version   "1.00"
//+------------------------------------------------------------------+
//| Script program start function                                    |
//+------------------------------------------------------------------+
void OnTick()
  {
   Comment(StringFormat("MQLTime:%s Local Time:%s", TimeToString(TimeCurrent(),TIME_SECONDS), TimeToString(TimeLocal(),TIME_SECONDS)) );   
   
  }
//+------------------------------------------------------------------+
Discover new MetaTrader 5 opportunities with MQL5 community and services
Discover new MetaTrader 5 opportunities with MQL5 community and services
  • 2022.08.26
  • www.mql5.com
MQL5: language of trade strategies built-in the MetaTrader 5 Trading Platform, allows writing your own trading robots, technical indicators, scripts and libraries of functions
 

The TimeTradeServer function can also be usefull:


TimeTradeServer

Returns the calculated current time of the trade server.
Unlike TimeCurrent(), the calculation of the time value is performed in the client terminal and depends on the time settings on your computer.