Author: Copyright � 2005, David W. Thomas
Daily Open

This custom indicator for MetaTrader is designed to provide visual reference points on a trading chart by automatically identifying and plotting two specific price levels: the Daily Open and the Euro Open.

Instead of requiring manual calculation, the tool scans the historical data to locate the exact opening prices at specific times and draws them as dashed lines on your screen. This allows traders to see at a glance how the current market price relates to these key structural levels throughout the trading day.

Key Functional Logic:

  • Automated Price Detection: The script continuously monitors the chart's timeline. It looks for specific moments where the minute is at zero and matches the hour against your predefined settings. When it finds these moments, it captures the "Open" price of that specific candle.
  • Daily Open Tracking: By default, the tool identifies the opening price of the new trading day. This creates a horizontal reference point, helping you determine if the market is trading above or below the previous day's starting point.
  • Euro Open Tracking: The script can also be configured to highlight the "Euro Open" (typically a significant session start for many currency pairs). You can customize the specific hour this occurs in the settings.
  • Visual Representation: Once these prices are identified, the tool plots them as dashed lines on the chart window. These lines remain consistent, providing a clear visual boundary for technical analysis and price action monitoring.
  • Performance Optimization: To ensure the platform remains responsive, the script is designed to focus its calculations on a specific recent window of data rather than recalculating the entire history of the asset every time the price moves.

In summary, this tool simplifies your technical analysis by automatically marking important session boundaries, allowing you to focus on trade execution rather than manual price tracking.

Miscellaneous
Implements a curve of type %1
7 Views
0 Downloads
0 Favorites
Daily Open
//+------------------------------------------------------------------+
//|                               Bunnygirl Cross and Daily Open.mq4 |
//|                                Copyright © 2005, David W. Thomas |
//|                                           mailto:davidwt@usa.net |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2005, David W. Thomas"
#property link      "mailto:davidwt@usa.net"

#property indicator_chart_window
#property indicator_buffers 2
#property indicator_color1 MediumSlateBlue
#property indicator_color2 ForestGreen

//---- input parameters

extern int DailyOpen=0;
extern int EuroOpen=8;


//---- buffers
double DailyOpenBuffer[];
double EuroOpenBuffer[];






//---- variables
int indexbegin = 0;
double dailyopen = 0,euroopen=0;



//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
{
//---- indicators
	SetIndexStyle(0, DRAW_LINE, STYLE_DASH);
	SetIndexBuffer(0, DailyOpenBuffer);
	SetIndexLabel(0, "Daily Open");
	SetIndexEmptyValue(0, 0.0);
	
		SetIndexStyle(1, DRAW_LINE, STYLE_DASH);
	SetIndexBuffer(1, EuroOpenBuffer);
	SetIndexLabel(1, "Euro Open");
	SetIndexEmptyValue(1, 0.0);


//----
	indexbegin = Bars - 20;
	if (indexbegin < 0)
		indexbegin = 0;


	return(0);
}
//+------------------------------------------------------------------+
//| Custor indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
{
//---- TODO: add your code here
	
//----
	return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
{
   int i;
	int counted_bars = IndicatorCounted();

	
	//---- check for possible errors
	if (counted_bars < 0) counted_bars = 0;
	//---- last counted bar will be recounted
	if (counted_bars > 0) counted_bars--;
	if (counted_bars > indexbegin) counted_bars = indexbegin;


		for (i = indexbegin-counted_bars; i >= 0; i--)
		{
			if ((TimeMinute(Time[i]) == 0) && (TimeHour(Time[i]) - DailyOpen == 0))
				dailyopen = Open[i];
			DailyOpenBuffer[i] = dailyopen;
			
			if ((TimeMinute(Time[i]) == 0) && (TimeHour(Time[i]) - EuroOpen == 0))
				euroopen = Open[i];
			EuroOpenBuffer[i] = euroopen;
			}

	
	return(0);

}
//+------------------------------------------------------------------+

Comments