daily_open_line GMT 2 LA
Download scriptThis tool is designed to provide traders with a clear, visual reference for the daily opening price on a trading chart. By highlighting where the market began at the start of each new day, it allows users to easily identify key psychological and technical support or resistance levels.
Core Functionality
The primary purpose of this script is to draw a continuous horizontal line that represents the "Opening Price" for every day. Instead of requiring the trader to manually check what price the market opened at, the tool automatically identifies these points and carries that specific price forward across the chart until the next day begins.
How the Logic Works
- Timezone Awareness: The script includes a customizable setting that allows users to adjust for different timezones. This ensures that the "Daily Open" is accurately identified based on the user's specific market hours rather than just the platform's default clock.
- Day Change Detection: The system constantly scans the historical price data to find the exact moment the calendar day changes. When it detects a new day starting, it captures the price of the very first candle.
- Continuous Line Mapping: Once the opening price for a new day is captured, the script "projects" that price forward. This creates a smooth horizontal line across all subsequent candles of that same day.
- Visual Clarity: The logic includes a specific instruction to prevent "staircasing" or jagged lines between days. It ensures that the transition from one day's opening price to the next is clean and distinct, making it easier for the trader to read the current day's levels at a glance.
Summary for the Trader
Essentially, this script acts as a visual "anchor." By showing you exactly where the market opened today (and where it opened on previous days), it helps you gauge whether the current price is trading significantly above or below the day's starting point, which is a common technique used in day trading to determine momentum and trend strength.
//*
//* 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 1
#property indicator_color1 Blue
#property indicator_style1 1
#property indicator_width1 5
double TodayOpenBuffer[];
extern int TimeZoneOfData= 2;
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
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= 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