daily_open_line_001

Download script
Author: Midnite
daily_open_line_001

This indicator is designed to provide traders with a clear visual reference for the opening price of each trading day. By identifying and plotting these specific price points, it helps users understand the daily baseline against which current market price movements can be measured.

Core Functionality

The script scans through your historical price data to identify the exact moment a new trading day begins. Once it detects this transition, it captures the opening price of that first candle and carries that value forward across the chart for the remainder of the day.

How the Logic Works

  • Timezone Adjustment: The tool allows for a customizable timezone offset. This ensures that the "start of the day" is accurately identified based on your specific local data, rather than defaulting to a generic global time.
  • Detection of New Days: The logic continuously compares the current date on the chart with the previous candle's date. When it detects a change (meaning a new calendar day has started), it triggers an action to record the price.
  • Price Mapping: Upon detecting a new day, the indicator grabs the "Open" price of that initial candle. It then projects this price horizontally across all subsequent candles until the next day's opening occurs.
  • Visual Smoothing: To ensure the chart remains clean and easy to read, the logic is designed to prevent "staircase" effects. It ensures the line connects smoothly from one day's open to the next, providing a continuous visual guide of where each day began.

Practical Use for Traders

Instead of manually looking up what price the market opened at today, this tool automatically draws that level on your screen. This allows you to see at a glance whether the current market price is trading above or below the daily open, which is a common technique used to determine daily momentum and trend direction.

Miscellaneous
Implements a curve of type %1
13 Views
0 Downloads
0 Favorites
daily_open_line_001
//*
//* my_DailyOpen_indicator
//*
//* Revision 1.1  2005/11/13 Midnite
//* Initial DailyOpen indicator
//* based pm  
//*
#property copyright "Midnite"
#property link      "me@home.net"

#property indicator_chart_window
#property indicator_buffers 2
#property indicator_color1 Magenta


double TodayOpenBuffer[];
extern int TimeZoneOfData= 0;
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
{
	SetIndexStyle(0,DRAW_SECTION,NULL);
	SetIndexBuffer(0,TodayOpenBuffer);
	SetIndexLabel(0,"Daily Open");
	SetIndexEmptyValue(0,0.0);
	return(0);
}
//+------------------------------------------------------------------+
//| Custor indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
{
	return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
{
   int lastbar;
   int counted_bars= IndicatorCounted();
   
   if (counted_bars>0) counted_bars--;
   lastbar = Bars-counted_bars;	
   DailyOpen(0,lastbar);
   
   return (0);
}
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
int DailyOpen(int offset, int lastbar)
{
   int shift;
   int tzdiffsec= TimeZoneOfData * 3600;
   double barsper30= 1.0*PERIOD_M30/Period();
   bool ShowDailyOpenLevel= True;
   // lastbar+= barsperday+2;  // make sure we catch the daily open		 
   lastbar= MathMin(Bars-20*barsper30-1, lastbar);

	for(shift=lastbar;shift>=offset;shift--){
	  TodayOpenBuffer[shift]= 0;
     if (ShowDailyOpenLevel){
       if(TimeDay(Time[shift]-tzdiffsec) != TimeDay(Time[shift+1]-tzdiffsec)){      // day change
         TodayOpenBuffer[shift]= Open[shift];         
         TodayOpenBuffer[shift+1]= 0;                                                           // avoid stairs in the line
       }
       else{
         TodayOpenBuffer[shift]= TodayOpenBuffer[shift+1];
       }
	  }
   }
   return(0);     
}

Comments