Daily_Open_Line mod-x

Download script
Author: Midnite
Daily_Open_Line mod-x

This tool is designed to help traders visualize a specific "Daily Open" price level on their trading charts. Instead of looking at the generic start of a day, this script allows you to pinpoint an exact moment—down to the specific hour and minute—to mark where the market opened based on your preferred time zone.

Core Functionality

Custom Time Selection The primary feature of this script is its flexibility regarding time. While many standard tools only allow you to mark the start of an hour (like 9:00 AM), this version allows you to input a precise time, including minutes. For example, if you want to track the price action starting at exactly 09:30 or 12:56, you can set those specific coordinates in the settings.

Automated Level Drawing Once you have defined your preferred start time, the script scans the historical price data to identify that exact moment. It then draws a continuous horizontal line on your chart. This line represents the opening price at your chosen time, providing a clear visual reference point for support, resistance, or trend analysis throughout the trading session.

Smart Line Behavior To ensure the chart remains clean and easy to read, the script is designed to prevent "staircase" effects. It ensures that the horizontal line remains steady and smooth as it moves across the price action, only updating when a new day cycle begins according to your specified time settings.

Input Validation and Safety To ensure the tool functions correctly without errors, the script includes built-in checks. If you accidentally enter an impossible time (such as an hour greater than 23 or minutes greater than 59), the system will provide an immediate alert notification. This ensures that the visual data on your chart remains accurate and reliable.

How it helps the trader

By providing a clear, horizontal visual of the "Daily Open" at a specific minute, this tool eliminates the need to manually scan through previous candles to find where the price started. It allows you to see at a glance how far the current market price has moved away from your designated opening point.

Miscellaneous
Implements a curve of type %1
9 Views
0 Downloads
0 Favorites
Daily_Open_Line mod-x
//*
//* my_DailyOpen_indicator
//*
//* Revision 1.1  2005/11/13 Midnite
//* Initial DailyOpen indicator
//
// *** The original indicator has input for drawing a horizontal line on the hour (9:00, 11:00, 15:00 etc) 
// *** but not past the hour (09:30, 15:15 etc).
// *** Edits by file45 : 
// *** Added - the ability to input minutes and set the horizontal line start time 
// *** at any minute past the hour (9:30, 10:42, 12:56 etc).
// *** Added - Alerts to hours entry > 23 and minutes entry > 59.

#property copyright "Midnite"
#property link      "me@home.net"

#property indicator_chart_window
#property indicator_buffers 1
#property indicator_color1 DodgerBlue
#property indicator_style1 0
#property indicator_width1 0

double TodayOpenBuffer[];
extern int Hour_= 9;
extern int Minutes = 30;
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()

{
   if (Hour_>23){
   Alert ("Please enter a value lower than 24 hours");
   return(0);}

   if (Minutes>59){
   Alert ("Please enter a value lower than 60 minutes");
   return (0);}
  
	SetIndexStyle(0,DRAW_LINE);
	SetIndexBuffer(0,TodayOpenBuffer);
	SetIndexLabel(0,"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= (Hour_*3600)+(Minutes*60);
   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