Ticks-MilSec

Download script
Ticks-MilSec

This script is designed as a diagnostic tool for the MetaTrader 4 platform to help traders and users monitor the real-time speed of price updates. Its primary purpose is to measure "latency" or the frequency of data "ticks" (the tiny movements in price) received from the broker's server.

Core Functionality

The script tracks how many milliseconds pass between each incoming price update. It organizes this data into a minute-by-minute breakdown, allowing you to see if the flow of information is smooth or experiencing delays at any specific point during the hour.

Key Logic Breakdown

  • Timeframe Restriction: To ensure accuracy, the script is specifically designed to run on the M1 (1 Minute) chart. If it is placed on any other timeframe, it will notify the user that the settings are incorrect.
  • Tick Calculation: The tool monitors the elapsed time between price changes. Every time a new tick arrives, the script calculates the difference in milliseconds from the previous update.
  • Averaging Mechanism: Rather than just showing raw numbers, the logic calculates an average millisecond count. This gives you a clear picture of the "heartbeat" of your connection—higher averages may indicate a slower data feed or network congestion.
  • Minute-by-Minute Reporting: The script creates a list for every minute of the hour (0 through 59). It captures:
    • The specific minute of the hour.
    • The total count of ticks received during that minute.
    • The average speed of those ticks in milliseconds.
  • Visual Feedback: The gathered data is displayed directly on your chart as a text summary. Additionally, the script identifies the current minute on the screen using a visible orange text label, making it easy to track where you are in the current hour while reviewing the performance data.

Summary for the User

Think of this tool as a "speedometer" for your trading data. It tells you how quickly your platform is receiving information from the market. By providing an average millisecond count per minute, it helps you identify if your connection is performing optimally or if there are specific times of day where price updates become sluggish.

11 Views
1 Downloads
0 Favorites
Ticks-MilSec
/*------------------------------------------------------------------+
 |                                                 Ticks-MilSec.mq4 |
 |                           Copyright © 2012, basisforex@gmail.com |
 +------------------------------------------------------------------*/ 
#property  copyright "Copyright © 2012, basisforex@gmail.com"
#property  link      "basisforex@gmail.com"
//+-----------------------------------------------------------------+   
#property indicator_chart_window
//------------------------------
int j, start, cnt;
double ar;
string S;
//--------   
int init()
 {
   return(0);
 }
//+------------------------------------------------------------------+
int deinit()
 {
   Comment("");
   ObjectDelete("txt");  
   return(0);
 }
//+------------------------------------------------------------------+
int start()
 {
   if (Period() != 1)
    {
		Comment("Not a right Period!!! It should be M1");
		return(0);	
	 }
   string t[60];  
   //==========
   if(Seconds() == 0)
    {
      cnt = 0;
      ar = 0;
    }
   for(j = 0; j <= 59; j++)
    {
      if(Minute() == j)
       {
         if(start == 0) start = GetTickCount();
         if(GetTickCount() - start > 0) 
          {
            cnt = cnt + 1;
            ar = ar + (GetTickCount() - start);
            start = 0;
          }
         if(cnt > 0)  t[j] = "Minute: " + DoubleToStr(j, 0) + "  Ticks #: "+  DoubleToStr(cnt, 0) + "    Avg= " + DoubleToStr(ar/cnt, 2) + " milliseconds" + "\n";  
       }
    }        
   //------
   Comment(t[0], t[1], t[2], t[3], t[4], t[5], t[6], t[7], t[8], t[9], t[10], t[11], t[12], t[13], t[14], t[15], t[16], t[17], t[18], t[19],
           t[20], t[21], t[22], t[23], t[24], t[25], t[26], t[27], t[28], t[29], t[30], t[31], t[32], t[33], t[34], t[35], t[36], t[37], t[38], t[39],
           t[40], t[41], t[42], t[43], t[44], t[45], t[46], t[47], t[48], t[49], t[50], t[51], t[52], t[53], t[54], t[55], t[56], t[57], t[58], t[59]);
   //------
   ObjectCreate("txt",OBJ_TEXT,0,TimeCurrent()- 60, Close[0] + 8 * Point);   
   ObjectSetText("txt", DoubleToStr(Minute(), 0), 16, "Times New Roman", Orange);
   ObjectMove("txt", 0, TimeCurrent()- 60, Close[0] + 8 * Point);
   //------
   return(0);
 }
//+------------------------------------------------------------------+

Comments