PROTECTED SOURCE SCRIPT
Premarket Break 5m (Close Above/Below Prem High/Low)

//version=5
indicator("Premarket Break 5m (Close Above/Below Prem High/Low)", overlay = true)
// === SETTINGS ===
premarketSession = input.session("0400-0930", "Premarket Session (ET)")
regularSession = input.session("0930-1600", "Regular Session (ET)")
// === HELPERS ===
isNewDay = ta.change(time("D")) != 0
// Track premarket high/low each day
var float pmHigh = na
var float pmLow = na
// Reset at the start of each new day
if isNewDay
pmHigh := na
pmLow := na
// Are we inside premarket session?
inPremarket = not na(time(timeframe.period, premarketSession, "America/New_York"))
// Update premarket high/low during premarket
if inPremarket
pmHigh := na(pmHigh) ? high : math.max(pmHigh, high)
pmLow := na(pmLow) ? low : math.min(pmLow, low)
// Are we inside regular session?
inRegular = not na(time(timeframe.period, regularSession, "America/New_York"))
// === SIGNALS: 5m close above/below premarket high/low ===
// Require previous close to be on the other side to avoid spam
bullBreak = inRegular and not na(pmHigh) and close > pmHigh and close[1] <= pmHigh
bearBreak = inRegular and not na(pmLow) and close < pmLow and close[1] >= pmLow
// === PLOTS ===
plot(pmHigh, title = "Premarket High", color = color.new(color.green, 0), linewidth = 2)
plot(pmLow, title = "Premarket Low", color = color.new(color.red, 0), linewidth = 2)
plotshape(bullBreak, title = "Close Above Prem High", style = shape.labelup,
text = "Close > PM High", location = location.belowbar, size = size.tiny)
plotshape(bearBreak, title = "Close Below Prem Low", style = shape.labeldown,
text = "Close < PM Low", location = location.abovebar, size = size.tiny)
// === ALERTS ===
// These fire once per bar close when the condition is true
if bullBreak
alert("5m candle CLOSED above Premarket High.", alert.freq_once_per_bar_close)
if bearBreak
alert("5m candle CLOSED below Premarket Low.", alert.freq_once_per_bar_close)
indicator("Premarket Break 5m (Close Above/Below Prem High/Low)", overlay = true)
// === SETTINGS ===
premarketSession = input.session("0400-0930", "Premarket Session (ET)")
regularSession = input.session("0930-1600", "Regular Session (ET)")
// === HELPERS ===
isNewDay = ta.change(time("D")) != 0
// Track premarket high/low each day
var float pmHigh = na
var float pmLow = na
// Reset at the start of each new day
if isNewDay
pmHigh := na
pmLow := na
// Are we inside premarket session?
inPremarket = not na(time(timeframe.period, premarketSession, "America/New_York"))
// Update premarket high/low during premarket
if inPremarket
pmHigh := na(pmHigh) ? high : math.max(pmHigh, high)
pmLow := na(pmLow) ? low : math.min(pmLow, low)
// Are we inside regular session?
inRegular = not na(time(timeframe.period, regularSession, "America/New_York"))
// === SIGNALS: 5m close above/below premarket high/low ===
// Require previous close to be on the other side to avoid spam
bullBreak = inRegular and not na(pmHigh) and close > pmHigh and close[1] <= pmHigh
bearBreak = inRegular and not na(pmLow) and close < pmLow and close[1] >= pmLow
// === PLOTS ===
plot(pmHigh, title = "Premarket High", color = color.new(color.green, 0), linewidth = 2)
plot(pmLow, title = "Premarket Low", color = color.new(color.red, 0), linewidth = 2)
plotshape(bullBreak, title = "Close Above Prem High", style = shape.labelup,
text = "Close > PM High", location = location.belowbar, size = size.tiny)
plotshape(bearBreak, title = "Close Below Prem Low", style = shape.labeldown,
text = "Close < PM Low", location = location.abovebar, size = size.tiny)
// === ALERTS ===
// These fire once per bar close when the condition is true
if bullBreak
alert("5m candle CLOSED above Premarket High.", alert.freq_once_per_bar_close)
if bearBreak
alert("5m candle CLOSED below Premarket Low.", alert.freq_once_per_bar_close)
受保護腳本
此腳本以閉源形式發佈。 不過,您可以自由使用,沒有任何限制 — 點擊此處了解更多。
免責聲明
這些資訊和出版物並非旨在提供,也不構成TradingView提供或認可的任何形式的財務、投資、交易或其他類型的建議或推薦。請閱讀使用條款以了解更多資訊。
受保護腳本
此腳本以閉源形式發佈。 不過,您可以自由使用,沒有任何限制 — 點擊此處了解更多。
免責聲明
這些資訊和出版物並非旨在提供,也不構成TradingView提供或認可的任何形式的財務、投資、交易或其他類型的建議或推薦。請閱讀使用條款以了解更多資訊。