ServerTime
Download scriptThis script is designed to provide real-time information directly on your trading platform's interface. Its primary purpose is to display a live clock that shows the current time of the server, allowing you to keep track of market sessions and timing without needing to look at an external clock.
Core Functionality
The logic follows a simple three-step lifecycle to ensure the information remains visible and accurate:
- Setup Phase: When you first load the script onto your chart, it creates a dedicated visual element (a text label) in the top corner of your screen. It sets specific parameters for this label, such as its font style, size, and color, ensuring that the information is easy to read against your trading background.
- Active Monitoring: Once the script is running, it continuously monitors the system's time. Every time the platform refreshes, the script fetches the most recent "Server Time" (the time used by the broker to price assets). It then instantly updates the text on your screen to reflect the current hour, minute, and second.
- Cleanup: To keep your workspace tidy, the script includes a removal instruction. If you decide to turn off or remove the indicator from your chart, it automatically deletes the text label, ensuring that no leftover visual elements remain on your screen.
User Experience
For the user, this means having a persistent, live-updating timestamp that remains consistent with the trading environment. It provides a seamless way to coordinate trades with specific market events or time zones in real-time.
//+------------------------------------------------------------------+
//| ServerTime.mq4 |
//| Copyright © 2005, komposter |
//| mailto:komposterius@mail.ru |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2005, komposter"
#property link "mailto:komposterius@mail.ru"
#property indicator_chart_window
extern color TextColor = Black;
//----
int init()
{
ObjectCreate( "ServerTime", OBJ_LABEL, 0,0,0,0,0,0,0);
ObjectSet( "ServerTime", OBJPROP_CORNER, 0);
ObjectSet( "ServerTime", OBJPROP_XDISTANCE, 0);
ObjectSet( "ServerTime", OBJPROP_YDISTANCE, 12);
ObjectSetText( "ServerTime", "", 12, "Arial", TextColor);
return(0);
}
//----
int deinit()
{
ObjectDelete("ServerTime");
return(0);
}
//----
int start()
{
ObjectSetText("ServerTime", TimeToStr( CurTime(), TIME_SECONDS ), 12, "Arial", TextColor );
return(0);
}
//+------------------------------------------------------------------+
Comments