Find Data Holes_v1

Download script
Author: Copyright � 2005, Luis Guilherme Damiani
Find Data Holes_v1

This script is designed to analyze historical market price data on your trading chart to identify "data holes"—periods where the price action is missing or disconnected. In electronic trading, these gaps can occur due to server outages, internet disconnections, or significant periods of inactivity where no trades were recorded.

How the Logic Works

The script scans your entire price history bar by bar, comparing the timestamp of each current candle against the one immediately preceding it. It looks for a specific discrepancy in time: if the gap between two consecutive candles exceeds a predefined threshold (based on the timeframe you are currently viewing), the script flags that section as a "hole."

How It Identifies Different Types of Gaps

The tool distinguishes between two types of gaps to help you understand why the data is missing:

  • Weekend Breaks: If the gap occurs between a Friday and a Monday, the script recognizes this as a standard weekend closure. It marks these specific points on your chart with a lime-colored arrow. This helps you differentiate between normal market holidays and actual technical errors.
  • Data Holes: If the gap is found during a weekday or an active trading period, the script identifies it as a genuine data "hole." It marks these locations on your chart with a specific symbol and maintains an internal counter to track how many of these instances occur across your history.

Final Output

Once the analysis is complete, the script provides a summary notification. This alert tells you exactly how many data holes were discovered within the loaded history. By using this tool, you can quickly verify the integrity of your historical data, ensuring that your backtesting or technical analysis isn't being skewed by missing price information.

Price Data Components
Series array that contains open time of each bar
Miscellaneous
It issuies visual alerts to the screen
7 Views
0 Downloads
0 Favorites
Find Data Holes_v1
/*-----------------------------+
|			       |
| Shared by www.Aptrafx.com    |
|			       |
+------------------------------*/

//+------------------------------------------------------------------+
//|                                              Find Data Holes.mq4 |
//|                         Copyright © 2005, Luis Guilherme Damiani |
//|                                      http://www.damianifx.com.br |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2005, Luis Guilherme Damiani"
#property link      "http://www.damianifx.com.br"
int hole_count=0;
int hole_size=2;
//+------------------------------------------------------------------+
//| script program start function                                    |
//+------------------------------------------------------------------+
int start()
  {
  
//---- 
   for(int i=0;i<Bars;i++)
   {
      if (iTime(NULL,0,i)-iTime(NULL,0,i+1)>Period()*hole_size*60+30)
      {
         if(TimeDayOfWeek(iTime(NULL,0,i+1))==5 && TimeDayOfWeek(iTime(NULL,0,i))== 1)
         {
               ObjectCreate("Weekend"+i,OBJ_ARROW,0,Time[i], Low[i]);
               ObjectSet("Weekend"+i,OBJPROP_COLOR,Lime);
         }
         else 
         {
            ObjectCreate("Hole"+i,OBJ_ARROW,0,Time[i], Low[i]);
            ObjectSet("Hole"+i,OBJPROP_ARROWCODE,251);
            hole_count=hole_count+1;
         }
      }
   }
   Alert(hole_count+"  holes were found, of size: "+hole_size+" bars.");
//----
   return(0);
  }
//+------------------------------------------------------------------+

Comments