Midnight Open NY Time
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// ©ALPHAICTRADER
//@version=5

indicator("Midnight Open", "Midnight Open", true, max_lines_count=500)

iMTime    = input.session ('0000-0001:1234567', "Session", group="New York Midnight Open")
iMStyle   = input.string  ("Dashed", "Line Style", options=["Solid", "Dotted", "Dashed"], group="New York Midnight Open")
iMColor   = input.color   (color.new(#58A2B0,52), "Color", group="New York Midnight Open")
iMLabel   = input.bool    (true, "Show Label", group="New York Midnight Open")


tMidnight = time          ("1", iMTime)

_MStyle   = iMStyle ==    "Solid" ? line.style_solid : iMStyle == "Dotted" ? line.style_dotted : line.style_dashed


var line lne = na
var openMidnight  = 0.0

if tMidnight
    if not tMidnight[1]
        openMidnight  := open
    else
        openMidnight := math.max(open, openMidnight)
if openMidnight != openMidnight[1]
    if barstate.isconfirmed
        line.set_x2(lne, tMidnight)
        lne := line.new(tMidnight, openMidnight, last_bar_time + 14400000/2, openMidnight, xloc.bar_time, extend.none, iMColor, _MStyle, 1)

//===========================
