Plot Horizontal line from date to date ( Monday to Friday)

Hi Guys,
I need to plot a Horizontal line for price boundaries, usually from Monday to Friday. I´ve found at the forum some examples for plotting lines on a particular date using valuewhen or look up, but not just until an end date.
Can you help me, please?

Best,

R.

How about knowledge base of AmiBroker. Lots of basic stuff there.

Such as this one
http://www.amibroker.com/kb/2014/11/18/how-to-plot-daily-high-and-low-on-intraday-chart/

Obviously you would just have to modify from inDaily to inWeekly to plot weekly high/low boundaries on shorter intervals.

If that is not what you want then please read here before creating next post.

Hi fxshrat, Thx for your comment!
I´ve found some threads about ploting lines from a date or High/Low. No problem for that. But what i´m looking for is to plot the line until an end date still not present on chart, so i don´t have any data for the week, Highs, Lows, etc. I will use this indicator on Mondays at opening time for creating some boundaries price valid for all week. I expect to have better explained now.

Here you go...

Replace arrays of variables arr1 and arr2 by your own ones.

/// @link https://forum.amibroker.com/t/plot-horizontal-line-from-date-to-date-monday-to-friday/17005/3
dow = DayOfWeek();
new_week = dow < Ref(dow, -1);
///
arr1 = Ref(H,-1);
value1 = ValueWhen(new_week, arr1);//  start of week value
///
arr2 = Ref(L,-1);
value2 = ValueWhen(new_week, arr2);//  start of week value
///
Plot( C, "", colorDefault, styleBar );
///
Plot(IIf( dow < 5, value1, Null), "", color = colorRed, style = styleDashed | styleThick);
Plot(IIf( dow > 1 AND dow <= 5, value1, Null), "", color, style, Null, Null, xshift = 1  );
///
Plot(IIf( dow < 5, value2, Null), "", color, style = styleDashed | styleThick );
Plot(IIf( dow > 1 AND dow <= 5, value2, Null), "", color, style, Null, Null, xshift = 1 );
///
_N( Title = StrFormat( "{{NAME}} - {{INTERVAL}} - {{DATE}} Open %g, Hi %g, Lo %g, Close %g (%.1f%%), Vol %g, %s value1: %g, value2: %g {{VALUES}}",
                           O, H, L, C, SelectedValue( ROC( C, 1 ) ), V, EncodeColor(colorRed), value1, value2 ) );

11

1 Like

Great fxshrat!
Thanks for your help!