OPEN-SOURCE SCRIPT
Actualizado MPX3

Orb boxes and session highs/lows
tells //version=6
indicator("MGC Part 1: The Map [Line Toggles]", overlay=true, max_boxes_count=100, max_lines_count=100, max_labels_count=100)
// ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
// 1. COLORS & SETTINGS
// ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
c_asia = input.color(#3179f5, "Asia Blue")
c_lon = input.color(#f23645, "London Red")
c_ny = input.color(#089981, "NY Green")
c_ny_mid = input.color(#9c27b0, "NY Mid Purple")
c_pd = input.color(#ffffff, "PDH/PDL White")
c_day = input.color(color.new(color.gray, 50), "Day Separator")
tz = input.string("GMT+10", "Timezone")
// --- NEW TOGGLES ---
show_asia_lines = input.bool(true, "Show Asia High/Low Lines")
show_lon_lines = input.bool(true, "Show London High/Low Lines")
show_ny_lines = input.bool(true, "Show NY High/Low Lines")
show_pd_lines = input.bool(true, "Show PDH/PDL Lines")
// ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
// 2. TIMING & DATA
// ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
int h = hour(time, tz)
int m = minute(time, tz)
string current_date = str.tostring(dayofmonth(time, tz), "00") + "/" + str.tostring(month(time, tz), "00")
[h5, l5] = request.security(syminfo.tickerid, "5", [high, low], lookahead=barmerge.lookahead_on)
bool t_asia = h == 9 and m == 0
bool t_lon = h == 18 and m == 0
bool t_ny = h == 23 and m == 0
bool t_ny_mid = h == 0 and m == 30
int t_project = time + 14400000
// ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
// 3. DAY SEPARATORS & PDH/PDL
// ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
bool new_day = ta.change(time("D")) != 0
[pdh, pdl] = request.security(syminfo.tickerid, "D", [high[1], low[1]], lookahead=barmerge.lookahead_off)
var line l_pdh = na, var line l_pdl = na
var label lb_pdh = na, var label lb_pdl = na
if new_day
line.delete(l_pdh), line.delete(l_pdl)
label.delete(lb_pdh), label.delete(lb_pdl)
line.new(time, low, time, high, xloc=xloc.bar_time, color=c_day, style=line.style_dotted, extend=extend.both)
if show_pd_lines
l_pdh := line.new(time, pdh, t_project, pdh, xloc=xloc.bar_time, color=c_pd, style=line.style_dashed)
l_pdl := line.new(time, pdl, t_project, pdl, xloc=xloc.bar_time, color=c_pd, style=line.style_dashed)
lb_pdh := label.new(t_project, pdh, "PDH (" + current_date + ")", xloc=xloc.bar_time, textcolor=c_pd, style=label.style_none, size=size.small)
lb_pdl := label.new(t_project, pdl, "PDL (" + current_date + ")", xloc=xloc.bar_time, textcolor=c_pd, style=label.style_none, size=size.small)
// ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
// 4. ORB BOXES
// ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
if t_asia
box.new(time, h5, time + 300000, l5, xloc=xloc.bar_time, bgcolor=color.new(c_asia, 85), border_color=c_asia, text="ASIA\n"+current_date, text_color=color.white, text_size=size.tiny)
if t_lon
box.new(time, h5, time + 300000, l5, xloc=xloc.bar_time, bgcolor=color.new(c_lon, 85), border_color=c_lon, text="LON\n"+current_date, text_color=color.white, text_size=size.tiny)
if t_ny
box.new(time, h5, time + 300000, l5, xloc=xloc.bar_time, bgcolor=color.new(c_ny, 85), border_color=c_ny, text="NY\n"+current_date, text_color=color.white, text_size=size.tiny)
if t_ny_mid
box.new(time, h5, time + 300000, l5, xloc=xloc.bar_time, bgcolor=color.new(c_ny_mid, 85), border_color=c_ny_mid, text="NY MID\n"+current_date, text_color=color.white, text_size=size.tiny)
// ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
// 5. SESSION TRACKING
// ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
// Asia
var line lah = na, var line lal = na, var label lbah = na, var label lbal = na
bool s_asia = (h >= 9 and h < 16)
if s_asia and show_asia_lines
if not s_asia[1]
lah := line.new(time, h5, t_project, h5, xloc=xloc.bar_time, color=c_asia)
lal := line.new(time, l5, t_project, l5, xloc=xloc.bar_time, color=c_asia)
lbah := label.new(t_project, h5, "Asia Hi ("+current_date+")", xloc=xloc.bar_time, textcolor=c_asia, style=label.style_none, size=size.small)
lbal := label.new(t_project, l5, "Asia Lo ("+current_date+")", xloc=xloc.bar_time, textcolor=c_asia, style=label.style_none, size=size.small)
else
if h5 > line.get_y1(lah)
line.set_y1(lah, h5), line.set_y2(lah, h5), label.set_y(lbah, h5)
if l5 < line.get_y1(lal)
line.set_y1(lal, l5), line.set_y2(lal, l5), label.set_y(lbal, l5)
// London
var line llh = na, var line lll = na, var label lblh = na, var label lbll = na
bool s_lon = (h >= 18 and h < 23)
if s_lon and show_lon_lines
if not s_lon[1]
llh := line.new(time, h5, t_project, h5, xloc=xloc.bar_time, color=c_lon)
lll := line.new(time, l5, t_project, l5, xloc=xloc.bar_time, color=c_lon)
lblh := label.new(t_project, h5, "Lon Hi ("+current_date+")", xloc=xloc.bar_time, textcolor=c_lon, style=label.style_none, size=size.small)
lbll := label.new(t_project, l5, "Lon Lo ("+current_date+")", xloc=xloc.bar_time, textcolor=c_lon, style=label.style_none, size=size.small)
else
if h5 > line.get_y1(llh)
line.set_y1(llh, h5), line.set_y2(llh, h5), label.set_y(lblh, h5)
if l5 < line.get_y1(lll)
line.set_y1(lll, l5), line.set_y2(lll, l5), label.set_y(lbll, l5)
// NY
var line lnh = na, var line lnl = na, var label lbnh = na, var label lbnl = na
bool s_ny = (h >= 23) or (h < 5)
if s_ny and show_ny_lines
if not s_ny[1]
lnh := line.new(time, h5, t_project, h5, xloc=xloc.bar_time, color=c_ny)
lnl := line.new(time, l5, t_project, l5, xloc=xloc.bar_time, color=c_ny)
lbnh := label.new(t_project, h5, "NY Hi ("+current_date+")", xloc=xloc.bar_time, textcolor=c_ny, style=label.style_none, size=size.small)
lbnl := label.new(t_project, l5, "NY Lo ("+current_date+")", xloc=xloc.bar_time, textcolor=c_ny, style=label.style_none, size=size.small)
else
if h5 > line.get_y1(lnh)
line.set_y1(lnh, h5), line.set_y2(lnh, h5), label.set_y(lbnh, h5)
if l5 < line.get_y1(lnl)
line.set_y1(lnl, l5), line.set_y2(lnl, l5), label.set_y(lbnl, l5)
// ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
// 6. GLOBAL EXTENSIONS
// ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
if show_asia_lines
line.set_x2(lah, t_project), line.set_x2(lal, t_project), label.set_x(lbah, t_project), label.set_x(lbal, t_project)
if show_lon_lines
line.set_x2(llh, t_project), line.set_x2(lll, t_project), label.set_x(lblh, t_project), label.set_x(lbll, t_project)
if show_ny_lines
line.set_x2(lnh, t_project), line.set_x2(lnl, t_project), label.set_x(lbnh, t_project), label.set_x(lbnl, t_project)
if show_pd_lines
line.set_x2(l_pdh, t_project), line.set_x2(l_pdl, t_project), label.set_x(lb_pdh, t_project), label.set_x(lb_pdl, t_project)
tells //version=6
indicator("MGC Part 1: The Map [Line Toggles]", overlay=true, max_boxes_count=100, max_lines_count=100, max_labels_count=100)
// ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
// 1. COLORS & SETTINGS
// ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
c_asia = input.color(#3179f5, "Asia Blue")
c_lon = input.color(#f23645, "London Red")
c_ny = input.color(#089981, "NY Green")
c_ny_mid = input.color(#9c27b0, "NY Mid Purple")
c_pd = input.color(#ffffff, "PDH/PDL White")
c_day = input.color(color.new(color.gray, 50), "Day Separator")
tz = input.string("GMT+10", "Timezone")
// --- NEW TOGGLES ---
show_asia_lines = input.bool(true, "Show Asia High/Low Lines")
show_lon_lines = input.bool(true, "Show London High/Low Lines")
show_ny_lines = input.bool(true, "Show NY High/Low Lines")
show_pd_lines = input.bool(true, "Show PDH/PDL Lines")
// ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
// 2. TIMING & DATA
// ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
int h = hour(time, tz)
int m = minute(time, tz)
string current_date = str.tostring(dayofmonth(time, tz), "00") + "/" + str.tostring(month(time, tz), "00")
[h5, l5] = request.security(syminfo.tickerid, "5", [high, low], lookahead=barmerge.lookahead_on)
bool t_asia = h == 9 and m == 0
bool t_lon = h == 18 and m == 0
bool t_ny = h == 23 and m == 0
bool t_ny_mid = h == 0 and m == 30
int t_project = time + 14400000
// ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
// 3. DAY SEPARATORS & PDH/PDL
// ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
bool new_day = ta.change(time("D")) != 0
[pdh, pdl] = request.security(syminfo.tickerid, "D", [high[1], low[1]], lookahead=barmerge.lookahead_off)
var line l_pdh = na, var line l_pdl = na
var label lb_pdh = na, var label lb_pdl = na
if new_day
line.delete(l_pdh), line.delete(l_pdl)
label.delete(lb_pdh), label.delete(lb_pdl)
line.new(time, low, time, high, xloc=xloc.bar_time, color=c_day, style=line.style_dotted, extend=extend.both)
if show_pd_lines
l_pdh := line.new(time, pdh, t_project, pdh, xloc=xloc.bar_time, color=c_pd, style=line.style_dashed)
l_pdl := line.new(time, pdl, t_project, pdl, xloc=xloc.bar_time, color=c_pd, style=line.style_dashed)
lb_pdh := label.new(t_project, pdh, "PDH (" + current_date + ")", xloc=xloc.bar_time, textcolor=c_pd, style=label.style_none, size=size.small)
lb_pdl := label.new(t_project, pdl, "PDL (" + current_date + ")", xloc=xloc.bar_time, textcolor=c_pd, style=label.style_none, size=size.small)
// ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
// 4. ORB BOXES
// ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
if t_asia
box.new(time, h5, time + 300000, l5, xloc=xloc.bar_time, bgcolor=color.new(c_asia, 85), border_color=c_asia, text="ASIA\n"+current_date, text_color=color.white, text_size=size.tiny)
if t_lon
box.new(time, h5, time + 300000, l5, xloc=xloc.bar_time, bgcolor=color.new(c_lon, 85), border_color=c_lon, text="LON\n"+current_date, text_color=color.white, text_size=size.tiny)
if t_ny
box.new(time, h5, time + 300000, l5, xloc=xloc.bar_time, bgcolor=color.new(c_ny, 85), border_color=c_ny, text="NY\n"+current_date, text_color=color.white, text_size=size.tiny)
if t_ny_mid
box.new(time, h5, time + 300000, l5, xloc=xloc.bar_time, bgcolor=color.new(c_ny_mid, 85), border_color=c_ny_mid, text="NY MID\n"+current_date, text_color=color.white, text_size=size.tiny)
// ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
// 5. SESSION TRACKING
// ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
// Asia
var line lah = na, var line lal = na, var label lbah = na, var label lbal = na
bool s_asia = (h >= 9 and h < 16)
if s_asia and show_asia_lines
if not s_asia[1]
lah := line.new(time, h5, t_project, h5, xloc=xloc.bar_time, color=c_asia)
lal := line.new(time, l5, t_project, l5, xloc=xloc.bar_time, color=c_asia)
lbah := label.new(t_project, h5, "Asia Hi ("+current_date+")", xloc=xloc.bar_time, textcolor=c_asia, style=label.style_none, size=size.small)
lbal := label.new(t_project, l5, "Asia Lo ("+current_date+")", xloc=xloc.bar_time, textcolor=c_asia, style=label.style_none, size=size.small)
else
if h5 > line.get_y1(lah)
line.set_y1(lah, h5), line.set_y2(lah, h5), label.set_y(lbah, h5)
if l5 < line.get_y1(lal)
line.set_y1(lal, l5), line.set_y2(lal, l5), label.set_y(lbal, l5)
// London
var line llh = na, var line lll = na, var label lblh = na, var label lbll = na
bool s_lon = (h >= 18 and h < 23)
if s_lon and show_lon_lines
if not s_lon[1]
llh := line.new(time, h5, t_project, h5, xloc=xloc.bar_time, color=c_lon)
lll := line.new(time, l5, t_project, l5, xloc=xloc.bar_time, color=c_lon)
lblh := label.new(t_project, h5, "Lon Hi ("+current_date+")", xloc=xloc.bar_time, textcolor=c_lon, style=label.style_none, size=size.small)
lbll := label.new(t_project, l5, "Lon Lo ("+current_date+")", xloc=xloc.bar_time, textcolor=c_lon, style=label.style_none, size=size.small)
else
if h5 > line.get_y1(llh)
line.set_y1(llh, h5), line.set_y2(llh, h5), label.set_y(lblh, h5)
if l5 < line.get_y1(lll)
line.set_y1(lll, l5), line.set_y2(lll, l5), label.set_y(lbll, l5)
// NY
var line lnh = na, var line lnl = na, var label lbnh = na, var label lbnl = na
bool s_ny = (h >= 23) or (h < 5)
if s_ny and show_ny_lines
if not s_ny[1]
lnh := line.new(time, h5, t_project, h5, xloc=xloc.bar_time, color=c_ny)
lnl := line.new(time, l5, t_project, l5, xloc=xloc.bar_time, color=c_ny)
lbnh := label.new(t_project, h5, "NY Hi ("+current_date+")", xloc=xloc.bar_time, textcolor=c_ny, style=label.style_none, size=size.small)
lbnl := label.new(t_project, l5, "NY Lo ("+current_date+")", xloc=xloc.bar_time, textcolor=c_ny, style=label.style_none, size=size.small)
else
if h5 > line.get_y1(lnh)
line.set_y1(lnh, h5), line.set_y2(lnh, h5), label.set_y(lbnh, h5)
if l5 < line.get_y1(lnl)
line.set_y1(lnl, l5), line.set_y2(lnl, l5), label.set_y(lbnl, l5)
// ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
// 6. GLOBAL EXTENSIONS
// ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
if show_asia_lines
line.set_x2(lah, t_project), line.set_x2(lal, t_project), label.set_x(lbah, t_project), label.set_x(lbal, t_project)
if show_lon_lines
line.set_x2(llh, t_project), line.set_x2(lll, t_project), label.set_x(lblh, t_project), label.set_x(lbll, t_project)
if show_ny_lines
line.set_x2(lnh, t_project), line.set_x2(lnl, t_project), label.set_x(lbnh, t_project), label.set_x(lbnl, t_project)
if show_pd_lines
line.set_x2(l_pdh, t_project), line.set_x2(l_pdl, t_project), label.set_x(lb_pdh, t_project), label.set_x(lb_pdl, t_project)
Notas de prensa
//version=6indicator("MPX3", overlay = true, max_boxes_count = 100, max_lines_count = 100, max_labels_count = 100)
// ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
// 1) SETTINGS & INPUTS
// ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
gp_tz = "Timezone & General"
tz_mode = input.string("Manual", "Timezone Source", options = ["Exchange", "Manual"], group = gp_tz)
tz_val = input.string("GMT+10", "Manual GMT Offset", group = gp_tz)
tz = tz_mode == "Exchange" ? syminfo.timezone : tz_val
f_size = input.string(size.small, "Label Font Size", options = [size.tiny, size.small, size.normal, size.large], group = gp_tz)
gp_col = "Colors & Styles"
c_asia1 = input.color(#0d47a1, "Asia 1 (Dark Blue)", group = gp_col)
c_asia2 = input.color(#1e88e5, "Asia 2 (Mid Blue)", group = gp_col)
c_asia3 = input.color(#64b5f6, "Asia 3 (Light Blue)", group = gp_col)
c_lon = input.color(#b71c1c, "London (Red)", group = gp_col)
c_ny = input.color(#9c27b0, "NY Early (Light Purple)", group = gp_col)
c_nyse = input.color(#4b0082, "NYSE Open (Dark Purple)", group = gp_col)
c_pd = input.color(#ffffff, "PDH/PDL White", group = gp_col)
c_day = input.color(color.new(color.gray, 50), "Day Separator", group = gp_col)
gp_tog = "Visibility Toggles"
show_boxes = input.bool(true, "Show Session ORB Boxes", group = gp_tog)
show_asia = input.bool(true, "Show Asia Session Lines", group = gp_tog)
show_lon = input.bool(true, "Show London Session Lines", group = gp_tog)
show_ny = input.bool(true, "Show NY Session Lines", group = gp_tog)
show_pd = input.bool(true, "Show PDH/PDL Lines", group = gp_tog)
// ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
// 2) CORE DATA & TIMING
// ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
daily_atr = request.security(syminfo.tickerid, "D", ta.atr(20))
rsi_val = ta.rsi(close, 14)
above_vwap = close > ta.vwap(hlc3)
[h5, l5] = request.security(syminfo.tickerid, "5", [high, low], lookahead = barmerge.lookahead_on)
t_project = time + 14400000
current_date = str.tostring(dayofmonth(time, tz), "00") + "/" + str.tostring(month(time, tz), "00")
ts_today_at(ref_time, hh, mm) =>
timestamp(tz, year(ref_time, tz), month(ref_time, tz), dayofmonth(ref_time, tz), hh, mm)
h = hour(time, tz)
m = minute(time, tz)
// ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
// 3) ORB BOX LOGIC (REAL-TIME CENTERED)
// ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
var box active_box = na
var line active_mid = na
draw_orb(txt, col, start_time, end_time, top, bottom) =>
b = show_boxes ? box.new(start_time, top, end_time, bottom, xloc = xloc.bar_time, bgcolor = color.new(col, 88), border_color = col, text = txt + "\n" + current_date, text_color = color.white, text_size = f_size) : na
l = show_boxes ? line.new(start_time, (top + bottom) / 2, end_time, (top + bottom) / 2, xloc = xloc.bar_time, color = col, style = line.style_dashed) : na
[b, l]
t_a1 = (h == 9 and m == 0)
t_a2 = (h == 10 and m == 0)
t_a3 = (h == 11 and m == 0)
t_lon = (h == 18 and m == 0)
t_ny = (h == 23 and m == 0)
t_nyse = (h == 0 and m == 30)
if t_a1
[b, l] = draw_orb("ASIA 1", c_asia1, time, ts_today_at(time, 12, 0), h5, l5)
active_box := b, active_mid := l
if t_a2
[b, l] = draw_orb("ASIA 2", c_asia2, time, ts_today_at(time, 12, 0), h5, l5)
active_box := b, active_mid := l
if t_a3
[b, l] = draw_orb("ASIA 3", c_asia3, time, ts_today_at(time, 12, 0), h5, l5)
active_box := b, active_mid := l
if t_lon
[b, l] = draw_orb("LON", c_lon, time, time + 7200000, h5, l5)
active_box := b, active_mid := l
if t_ny
[b, l] = draw_orb("NY EARLY", c_ny, time, time + 7200000, h5, l5)
active_box := b, active_mid := l
if t_nyse
[b, l] = draw_orb("NYSE OPEN", c_nyse, time, time + 7200000, h5, l5)
active_box := b, active_mid := l
if not na(active_box)
bool updated = false
if h5 > box.get_top(active_box)
box.set_top(active_box, h5), updated := true
if l5 < box.get_bottom(active_box)
box.set_bottom(active_box, l5),
Script de código abierto
Fiel al espíritu de TradingView, el creador de este script lo ha convertido en código abierto, para que los traders puedan revisar y verificar su funcionalidad. ¡Enhorabuena al autor! Aunque puede utilizarlo de forma gratuita, recuerde que la republicación del código está sujeta a nuestras Normas internas.
Exención de responsabilidad
La información y las publicaciones no constituyen, ni deben considerarse como asesoramiento o recomendaciones financieras, de inversión, de trading o de otro tipo proporcionadas o respaldadas por TradingView. Más información en Condiciones de uso.
Script de código abierto
Fiel al espíritu de TradingView, el creador de este script lo ha convertido en código abierto, para que los traders puedan revisar y verificar su funcionalidad. ¡Enhorabuena al autor! Aunque puede utilizarlo de forma gratuita, recuerde que la republicación del código está sujeta a nuestras Normas internas.
Exención de responsabilidad
La información y las publicaciones no constituyen, ni deben considerarse como asesoramiento o recomendaciones financieras, de inversión, de trading o de otro tipo proporcionadas o respaldadas por TradingView. Más información en Condiciones de uso.