Home > Net >  Stop Drawing Lines at the End of Day
Stop Drawing Lines at the End of Day

Time:10-13

I need to stop drawing lines at the end of the day, Instead of crossing the day until the next session. I unsuccessly tried.

I need the solution please.

//@version=4
study(title="Opening Sessions", shorttitle="OS", overlay=true)
ops4_clr = color(#ff2b00)
input_ops4 = input("1330-1400", type=input.session, title="Open Session : ops4")
ops4_session = time(timeframe.period,input_ops4 ":1234567")
var ops4_hi = 0.0
var ops4_lo = 0.0
if ops4_session
if not ops4_session[1]
    ops4_lo := low
    ops4_hi := high
else
    ops4_lo := min(low , ops4_lo)
    ops4_hi := max(high, ops4_hi)
ops4_mid = ops4_lo   ((ops4_hi - ops4_lo) / 2)
// Plots
ops4_hi_plot = plot(not ops4_session ? ops4_hi : na, title="ops4H", color=ops4_clr, linewidth=1, style=plot.style_linebr)
ops4_lo_plot = plot(not ops4_session ? ops4_lo : na, title="ops4L", color=ops4_clr, linewidth=1, style=plot.style_linebr)
ops4_md_plot = plot(not ops4_session ? ops4_mid : na, title="ops4M", color=color.new(ops4_clr, 75), linewidth=1, style=plot.style_linebr)

CodePudding user response:

Not sure I understood your question (a picture paints a thousand words). But I think this might be what you are trying to achieve.

//@version=4
study(title="Delete Me", shorttitle="OS", overlay=true)
ops4_clr = color(#ff2b00)
input_ops4 = input("1330-1400", type=input.session, title="Open Session : ops4")
ops4_session = time(timeframe.period,input_ops4 ":1234567")
var ops4_hi = 0.0
var ops4_lo = 0.0
if ops4_session
    if not ops4_session[1]
        ops4_lo := low
        ops4_hi := high
    else
        ops4_lo := min(low , ops4_lo)
        ops4_hi := max(high, ops4_hi)
ops4_mid = ops4_lo   ((ops4_hi - ops4_lo) / 2)
// Plots

no_time = time(timeframe.period, "0001-1330:1234567")
ops4_hi_plot = plot(not no_time ? ops4_hi : na, title="ops4H", color=ops4_clr, linewidth=1, style=plot.style_linebr)
ops4_lo_plot = plot(not no_time ? ops4_lo : na, title="ops4L", color=ops4_clr, linewidth=1, style=plot.style_linebr)
ops4_md_plot = plot(not no_time ? ops4_mid : na, title="ops4M", color=color.new(ops4_clr, 75), linewidth=1, style=plot.style_linebr)
  • Related