OPEN-SOURCE SCRIPT
SWIFT ALGO X LIMITLESS

//version=5
//Shanxia
// NOTE: Only works on 1HR and below and exchange timezones differ so change the session times accordingly.
indicator("ICT NY Midnight Open", "ICT NY OPEN", true, max_lines_count=500, max_bars_back = 5000)
// INPUTS
i_time = input.session ('0000-0001:1234567', "New York", tooltip="Different exchanges will have difference time zones so change accordingly.")
i_tz = input ("GMT-4", "Timezone")
i_vline = input.bool (true, "VLine", inline="in3")
i_vcol = input.color (#00b9d0, "", inline="in3")
i_txtcol = input.color (#0098ff, " Text color", inline="in3")
i_vstyle = input.string ("Solid", "Style", options=["Solid", "Dotted", "Dashed"])
i_hline = input.bool (true, "HLine", inline="in1")
i_linecol = input.color (#0064ff, "", inline="in1")
i_linestyle = input.string ("Dotted", " ", options=["Solid", "Dotted", "Dashed"], inline="in1")
i_ex = input.string ("1 Day", "Extend", options=["1 Day", "2 Days", "Right", "Both"], inline="in4" )
i_ex2 = input.bool (false, "", inline="in4")
i_ex3 = input.int (3, "Hours", 1, 23, inline="in4")
// MISC
nymid = time ("1", i_time, i_tz)
linestyle = i_linestyle == "Solid" ? line.style_solid : i_linestyle == "Dotted" ? line.style_dotted : line.style_dashed
vstyle = i_vstyle == "Solid" ? line.style_solid : i_vstyle == "Dotted" ? line.style_dotted : line.style_dashed
ex = i_ex == "1 Day" ? extend.none : i_ex == "2 Days" ? extend.none : i_ex == "Right" ? extend.right : extend.both
htime = i_ex == "2 Days" ? 172800000 : 86400000
hourtime = i_ex2 ? i_ex3 * 3600000 : htime
// CALC
var openprice = 0.0
if nymid
if not nymid[1]
openprice := open
else
openprice := math.max(open, openprice)
// OBJECTS
var label lb = na
if openprice != openprice[1] and i_hline
var line lne = na
line.set_x2(lne, nymid)
line.set_extend(lne, extend.none)
lne := line.new(nymid, openprice, nymid + hourtime , openprice, xloc.bar_time, extend.none, i_linecol, linestyle, 2)
lb := label.new(nymid + htime, openprice, "NY Midnight Open | " + str.tostring(math.round_to_mintick(openprice)), xloc.bar_time, yloc.price, na, label.style_none, i_txtcol)
label.delete(lb[1])
if i_vline and nymid == nymid
vl1 = line.new(nymid, high, nymid, low, xloc.bar_time, extend.both, i_vcol, vstyle, 1)
if line.get_y1(vl1) == line.get_y2(vl1)
line.delete(vl1)
// END
//Shanxia
// NOTE: Only works on 1HR and below and exchange timezones differ so change the session times accordingly.
indicator("ICT NY Midnight Open", "ICT NY OPEN", true, max_lines_count=500, max_bars_back = 5000)
// INPUTS
i_time = input.session ('0000-0001:1234567', "New York", tooltip="Different exchanges will have difference time zones so change accordingly.")
i_tz = input ("GMT-4", "Timezone")
i_vline = input.bool (true, "VLine", inline="in3")
i_vcol = input.color (#00b9d0, "", inline="in3")
i_txtcol = input.color (#0098ff, " Text color", inline="in3")
i_vstyle = input.string ("Solid", "Style", options=["Solid", "Dotted", "Dashed"])
i_hline = input.bool (true, "HLine", inline="in1")
i_linecol = input.color (#0064ff, "", inline="in1")
i_linestyle = input.string ("Dotted", " ", options=["Solid", "Dotted", "Dashed"], inline="in1")
i_ex = input.string ("1 Day", "Extend", options=["1 Day", "2 Days", "Right", "Both"], inline="in4" )
i_ex2 = input.bool (false, "", inline="in4")
i_ex3 = input.int (3, "Hours", 1, 23, inline="in4")
// MISC
nymid = time ("1", i_time, i_tz)
linestyle = i_linestyle == "Solid" ? line.style_solid : i_linestyle == "Dotted" ? line.style_dotted : line.style_dashed
vstyle = i_vstyle == "Solid" ? line.style_solid : i_vstyle == "Dotted" ? line.style_dotted : line.style_dashed
ex = i_ex == "1 Day" ? extend.none : i_ex == "2 Days" ? extend.none : i_ex == "Right" ? extend.right : extend.both
htime = i_ex == "2 Days" ? 172800000 : 86400000
hourtime = i_ex2 ? i_ex3 * 3600000 : htime
// CALC
var openprice = 0.0
if nymid
if not nymid[1]
openprice := open
else
openprice := math.max(open, openprice)
// OBJECTS
var label lb = na
if openprice != openprice[1] and i_hline
var line lne = na
line.set_x2(lne, nymid)
line.set_extend(lne, extend.none)
lne := line.new(nymid, openprice, nymid + hourtime , openprice, xloc.bar_time, extend.none, i_linecol, linestyle, 2)
lb := label.new(nymid + htime, openprice, "NY Midnight Open | " + str.tostring(math.round_to_mintick(openprice)), xloc.bar_time, yloc.price, na, label.style_none, i_txtcol)
label.delete(lb[1])
if i_vline and nymid == nymid
vl1 = line.new(nymid, high, nymid, low, xloc.bar_time, extend.both, i_vcol, vstyle, 1)
if line.get_y1(vl1) == line.get_y2(vl1)
line.delete(vl1)
// END
Open-source script
In true TradingView spirit, the creator of this script has made it open-source, so that traders can review and verify its functionality. Kudos to the author! While you can use it for free, remember that republishing the code is subject to our House Rules.
Disclaimer
The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.
Open-source script
In true TradingView spirit, the creator of this script has made it open-source, so that traders can review and verify its functionality. Kudos to the author! While you can use it for free, remember that republishing the code is subject to our House Rules.
Disclaimer
The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.