How do I plot a vertical line on an intraday chart at the open?

I purchased some historical one minute data to look for recurring patterns. Amibroker plots a red line at 7am on the one minute chart. I want to quickly see where the open is by plotting a green line at 9:30am. Can anyone point me in the right direction?

Thanks,
John

You can use this code:

_SECTION_BEGIN( "First Bar" );
LineColor = ParamColor( "Line color", colorGreen );
//FirstBar = DateNum()!=Ref(DateNum(),-1); // First option
FirstBar = TimeNum() == 093000;  //  Second option
Plot( FirstBar, "", LineColor, styleArea | styleOwnScale | styleNoLabel | styleNoTitle, 1, 0, 0, 1, 1 );
_SECTION_END();

It plots a green vertical line at 9:30 or marks the first bar of a day (two options).

Regards :slight_smile:

8 Likes

Thank you sir! I was just reading about TimeNum.

Thank you Milosz

i add one more line in your code ValueWhen().
Just in case if tomorow our friends ask how to find a specific bar Close

 _SECTION_BEGIN( "First Bar" );
LineColor = ParamColor( "Line color", colorGreen );
//FirstBar = DateNum()!=Ref(DateNum(),-1); // First option
FirstBar = TimeNum() == 093000;  //  Second option
FirstBarClose= ValueWhen( FirstBar, C );  // specific bar Close 
Plot( FirstBar, "", LineColor, styleArea | styleOwnScale | styleNoLabel | styleNoTitle, 1, 0, 0, 1, 1 );
_SECTION_END();
 
 
Title= "TimeFrame (" + Interval(2)+") and Τime at 9:30  Close is, " +FirstBarClose;
6 Likes

This one will plot vertical line on every intraday timeframe

/// @link http://forum.amibroker.com/t/how-do-i-plot-a-vertical-line-on-an-intraday-chart-at-the-open/1458/5

Plot( C, "", colorDefault, styleCandle );

dn = DateNum();
starttime = ParamTime( "StartTime", "09:30:00" );
startcond = TimeNum() >= starttime;
newday = dn != Ref( dn, -1 );
startperiod = startcond != Ref( startcond, -1 ) AND ! newday;

Plot( startperiod, "", colorBlue, styleHistogram | styleOwnScale | styleNoLabel, 0, 1, 0, 0, -60 );

Title = StrFormat( "TimeFrame (" + Interval( 2 ) + ") and at Time " +
                   DateTimeFormat( "%H:%M:%S", DateTimeConvert( 2, 700101, starttime ) ) +
                   ", Close is: %g", SelectedValue( ValueWhen( startperiod, Close ) ) );
8 Likes

@Jcpilot
IMHO, a dynamic color scheme is better (to reflect the Opening Mood of the scrip) which you can easily achieve by a slight modification in any of the above codes kindly shared by the respective authors.

Thank you brothers .