OPEN-SOURCE SCRIPT
Futures Previous Day Levels (CME 5PM Correct) RAFE TRADER

//version=5
indicator("Futures Previous Day Levels (CME 5PM Correct)", overlay=true)
// ─── CONFIGURACIÓN ─────────────────────────────────────────────────────────────
tz = "America/New_York"
resetHour = 17 // 5:00 PM NY
// ─── TIEMPO ────────────────────────────────────────────────────────────────────
t = time(timeframe.period, tz)
h = hour(t)
m = minute(t)
// Detecta el reset EXACTO del día
isReset = (h == resetHour and m == 0)
// ─── VARIABLES DEL DÍA ACTUAL ──────────────────────────────────────────────────
var float curHigh = na
var float curLow = na
// ─── VARIABLES DEL DÍA ANTERIOR ────────────────────────────────────────────────
var float prevHigh = na
var float prevLow = na
var float prevClose = na
var float prevMid = na
// ─── INICIALIZACIÓN ────────────────────────────────────────────────────────────
if na(curHigh)
curHigh := high
curLow := low
// ─── ACTUALIZAR HIGH / LOW SOLO SI NO ES RESET ─────────────────────────────────
if not isReset
curHigh := math.max(curHigh, high)
curLow := math.min(curLow, low)
// ─── AL MOMENTO EXACTO DEL RESET (17:00) ───────────────────────────────────────
if isReset
// Guardamos EL DÍA QUE TERMINA
prevHigh := curHigh
prevLow := curLow
prevClose := close[1]
prevMid := (prevHigh + prevLow) / 2
// Iniciamos el nuevo día SOLO con esta vela
curHigh := high
curLow := low
// ─── DIBUJAR NIVELES ───────────────────────────────────────────────────────────
plot(prevHigh, title="Prev Day High", color=color.red, linewidth=2, style=plot.style_linebr)
plot(prevLow, title="Prev Day Low", color=color.green, linewidth=2, style=plot.style_linebr)
plot(prevMid, title="Prev Day Mid", color=color.orange, linewidth=2, style=plot.style_linebr)
plot(prevClose, title="Prev Day Close", color=color.purple, linewidth=2, style=plot.style_linebr)
indicator("Futures Previous Day Levels (CME 5PM Correct)", overlay=true)
// ─── CONFIGURACIÓN ─────────────────────────────────────────────────────────────
tz = "America/New_York"
resetHour = 17 // 5:00 PM NY
// ─── TIEMPO ────────────────────────────────────────────────────────────────────
t = time(timeframe.period, tz)
h = hour(t)
m = minute(t)
// Detecta el reset EXACTO del día
isReset = (h == resetHour and m == 0)
// ─── VARIABLES DEL DÍA ACTUAL ──────────────────────────────────────────────────
var float curHigh = na
var float curLow = na
// ─── VARIABLES DEL DÍA ANTERIOR ────────────────────────────────────────────────
var float prevHigh = na
var float prevLow = na
var float prevClose = na
var float prevMid = na
// ─── INICIALIZACIÓN ────────────────────────────────────────────────────────────
if na(curHigh)
curHigh := high
curLow := low
// ─── ACTUALIZAR HIGH / LOW SOLO SI NO ES RESET ─────────────────────────────────
if not isReset
curHigh := math.max(curHigh, high)
curLow := math.min(curLow, low)
// ─── AL MOMENTO EXACTO DEL RESET (17:00) ───────────────────────────────────────
if isReset
// Guardamos EL DÍA QUE TERMINA
prevHigh := curHigh
prevLow := curLow
prevClose := close[1]
prevMid := (prevHigh + prevLow) / 2
// Iniciamos el nuevo día SOLO con esta vela
curHigh := high
curLow := low
// ─── DIBUJAR NIVELES ───────────────────────────────────────────────────────────
plot(prevHigh, title="Prev Day High", color=color.red, linewidth=2, style=plot.style_linebr)
plot(prevLow, title="Prev Day Low", color=color.green, linewidth=2, style=plot.style_linebr)
plot(prevMid, title="Prev Day Mid", color=color.orange, linewidth=2, style=plot.style_linebr)
plot(prevClose, title="Prev Day Close", color=color.purple, linewidth=2, style=plot.style_linebr)
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.