OPEN-SOURCE SCRIPT
Líneas Sutiles - Aperturas y Cierres (Londres & NY)

//version=6
indicator("Líneas Sutiles - Aperturas y Cierres (Londres & NY)", overlay=true)
// Función para verificar si el timestamp pertenece al día actual o al anterior
isTodayOrYesterday(ts) =>
tsYear = year(ts, "America/New_York")
tsMonth = month(ts, "America/New_York")
tsDay = dayofmonth(ts, "America/New_York")
today = dayofmonth(timenow, "America/New_York")
thisMonth = month(timenow, "America/New_York")
thisYear = year(timenow, "America/New_York")
tsYear == thisYear and tsMonth == thisMonth and (tsDay == today or tsDay == today - 1)
// Horarios clave (en horario de Nueva York)
londonOpen = timestamp("America/New_York", year, month, dayofmonth, 2, 0)
londonClose = timestamp("America/New_York", year, month, dayofmonth, 5, 0)
preNY = timestamp("America/New_York", year, month, dayofmonth, 7, 0)
nyOpen = timestamp("America/New_York", year, month, dayofmonth, 7, 0)
nyDayStart = timestamp("America/New_York", year, month, dayofmonth, 17, 0) // 🔶 NUEVA línea 5PM NY
// Dibujar líneas sutiles solo si son del día actual o anterior
if (isTodayOrYesterday(londonOpen) and time == londonOpen)
line.new(x1=londonOpen, y1=low, x2=londonOpen, y2=high, xloc=xloc.bar_time, extend=extend.both, style=line.style_dotted, color=color.new(color.blue, 45), width=1)
if (isTodayOrYesterday(londonClose) and time == londonClose)
line.new(x1=londonClose, y1=low, x2=londonClose, y2=high, xloc=xloc.bar_time, extend=extend.both, style=line.style_dotted, color=color.new(color.blue, 45), width=1)
if (isTodayOrYesterday(preNY) and time == preNY)
line.new(x1=preNY, y1=low, x2=preNY, y2=high, xloc=xloc.bar_time, extend=extend.both, style=line.style_dotted, color=color.new(color.orange, 45), width=1)
if (isTodayOrYesterday(nyOpen) and time == nyOpen)
line.new(x1=nyOpen, y1=low, x2=nyOpen, y2=high, xloc=xloc.bar_time, extend=extend.both, style=line.style_dotted, color=color.new(color.red, 45), width=1)
// 🔶 Línea amarilla a las 5PM NY (inicio del día operativo)
if (isTodayOrYesterday(nyDayStart) and time == nyDayStart)
line.new(x1=nyDayStart, y1=low, x2=nyDayStart, y2=high, xloc=xloc.bar_time, extend=extend.both, style=line.style_dotted, color=color.new(color.yellow, 25), width=1)
indicator("Líneas Sutiles - Aperturas y Cierres (Londres & NY)", overlay=true)
// Función para verificar si el timestamp pertenece al día actual o al anterior
isTodayOrYesterday(ts) =>
tsYear = year(ts, "America/New_York")
tsMonth = month(ts, "America/New_York")
tsDay = dayofmonth(ts, "America/New_York")
today = dayofmonth(timenow, "America/New_York")
thisMonth = month(timenow, "America/New_York")
thisYear = year(timenow, "America/New_York")
tsYear == thisYear and tsMonth == thisMonth and (tsDay == today or tsDay == today - 1)
// Horarios clave (en horario de Nueva York)
londonOpen = timestamp("America/New_York", year, month, dayofmonth, 2, 0)
londonClose = timestamp("America/New_York", year, month, dayofmonth, 5, 0)
preNY = timestamp("America/New_York", year, month, dayofmonth, 7, 0)
nyOpen = timestamp("America/New_York", year, month, dayofmonth, 7, 0)
nyDayStart = timestamp("America/New_York", year, month, dayofmonth, 17, 0) // 🔶 NUEVA línea 5PM NY
// Dibujar líneas sutiles solo si son del día actual o anterior
if (isTodayOrYesterday(londonOpen) and time == londonOpen)
line.new(x1=londonOpen, y1=low, x2=londonOpen, y2=high, xloc=xloc.bar_time, extend=extend.both, style=line.style_dotted, color=color.new(color.blue, 45), width=1)
if (isTodayOrYesterday(londonClose) and time == londonClose)
line.new(x1=londonClose, y1=low, x2=londonClose, y2=high, xloc=xloc.bar_time, extend=extend.both, style=line.style_dotted, color=color.new(color.blue, 45), width=1)
if (isTodayOrYesterday(preNY) and time == preNY)
line.new(x1=preNY, y1=low, x2=preNY, y2=high, xloc=xloc.bar_time, extend=extend.both, style=line.style_dotted, color=color.new(color.orange, 45), width=1)
if (isTodayOrYesterday(nyOpen) and time == nyOpen)
line.new(x1=nyOpen, y1=low, x2=nyOpen, y2=high, xloc=xloc.bar_time, extend=extend.both, style=line.style_dotted, color=color.new(color.red, 45), width=1)
// 🔶 Línea amarilla a las 5PM NY (inicio del día operativo)
if (isTodayOrYesterday(nyDayStart) and time == nyDayStart)
line.new(x1=nyDayStart, y1=low, x2=nyDayStart, y2=high, xloc=xloc.bar_time, extend=extend.both, style=line.style_dotted, color=color.new(color.yellow, 25), width=1)
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.