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)
Script protégé
Ce script est publié en source fermée. Cependant, vous pouvez l'utiliser librement et sans aucune restriction – pour en savoir plus, cliquez ici.
Clause de non-responsabilité
Les informations et publications ne sont pas destinées à être, et ne constituent pas, des conseils ou recommandations financiers, d'investissement, de trading ou autres fournis ou approuvés par TradingView. Pour en savoir plus, consultez les Conditions d'utilisation.
Script protégé
Ce script est publié en source fermée. Cependant, vous pouvez l'utiliser librement et sans aucune restriction – pour en savoir plus, cliquez ici.
Clause de non-responsabilité
Les informations et publications ne sont pas destinées à être, et ne constituent pas, des conseils ou recommandations financiers, d'investissement, de trading ou autres fournis ou approuvés par TradingView. Pour en savoir plus, consultez les Conditions d'utilisation.