本页源码来自 TradingView 公开发布的开源脚本,版权归原作者所有, 请遵循其原始许可(Pine 脚本常见 CC BY-NC-SA / MPL-2.0 / MIT)。 本项目仅用于研究检索与许可范围内的移植。
// This Pine Script® code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © Darkmatter513
// @version=5
indicator("NTrades [ORBDD Advanced] - Working", overlay=true, max_labels_count=500, max_lines_count=500, max_boxes_count=500)
// This contains Base + R-Labels + EMA + Force Exit Logic + Daily Bias
// ═══════════════════════════════════════════════════════════════════════════════
// INPUTS
// ═══════════════════════════════════════════════════════════════════════════════
g_display = "📊 Display"
showSignals = input.bool(true, "Show Signals", group=g_display)
showORBox = input.bool(true, "Show Opening Range Box", group=g_display)
showTrend = input.bool(false, "Show Trend Line", group=g_display)
showFVG = false
showDashboard = input.bool(true, "Show Main Dashboard", group=g_display)
showStatsPanel = input.bool(false, "Show Range Stats Panel", group=g_display)
// --- DATE RANGE SECTION ---
g_date = "📅 Date Range Filter"
useDateFilter = input.bool(true, "Enable Date Filter", group=g_date)
startDate = input.time(timestamp("2025-08-01 00:00"), "Start Date", group=g_date)
endDate = input.time(timestamp("2026-02-10 23:45"), "End Date", group=g_date)
g_orb = "⏰ Opening Range Settings"
orbMinutes = input.int(15, "Opening Range Minutes", minval=5, maxval=60, step=5, group=g_orb)
sessionStart = input.session("0930-0945", "Opening Range Session", group=g_orb)
tradingEnd = input.int(14, "Stop New Entries After (Hour ET)", minval=10, maxval=16, group=g_orb, tooltip="Stop taking NEW trades after this hour (15 = 3PM)")
forceExitHour = input.int(15, "Force Exit All Trades (Hour ET)", minval=0, maxval=23, group=g_orb, tooltip="Set to 0 to DISABLE this feature.\nIf set to 13, 14, etc., all trades close immediately at that hour.")
g_entry = "🎯 Entry Settings"
entryType = input.string("Retest", "Entry Type", options=["Breakout", "Retest"], group=g_entry, tooltip="Breakout: Enter immediately on break\nRetest: Wait for pullback to range")
requireVolume = input.bool(false, "Require Volume Confirmation", group=g_entry)
requireFVG = input.bool(false, "Require FVG Confluence", group=g_entry)
// --- TREND FILTER SECTION ---
g_trend = "🌊 Trend Filter (Reduce Losers)"
useTrendFilter = input.bool(false, "Enable Trend Filter", group=g_trend, tooltip="Only take Longs above EMA and Shorts below EMA.")
trendLen = input.int(50, "EMA Period", minval=10, step=10, group=g_trend, tooltip="50 is good for intermediate trend. 200 is for major trend.")
// --- DAILY DIRECTION FILTER SECTION ---
g_dailyDir = "🧭 Daily Direction Filter"
useDailyDir = input.bool(true, "Enable Strict Daily Direction", group=g_dailyDir, tooltip="Longs: Yesterday closed > day before, OR yesterday swept day before's low and closed back above it.\nShorts: Inverse.")
g_risk = "💰 Risk Management"
slType = input.string("Midpoint", "Stop Loss Placement", options=["Opposite Side", "Midpoint", "ATR Based"], group=g_risk)
rrRatio = input.float(1.4, "Risk:Reward Ratio", minval=1.0, maxval=10.0, step=0.1, group=g_risk)
g_filter = "🔍 Range (Risk) Filter"
useRangeFilter = input.bool(true, "Enable Max Range Filter", group=g_filter)
maxRiskPoints = input.float(220.0, "Max 1R Size (Price Points)", group=g_filter, tooltip="If the distance between Entry and Stop Loss is greater than this value, the trade is skipped.")
// ═══════════════════════════════════════════════════════════════════════════════
// COLORS
// ═══════════════════════════════════════════════════════════════════════════════
bullColor = #00E676
bearColor = #FF5252
orbColor = #2196F3
fvgBullColor = color.new(#00E676, 85)
fvgBearColor = color.new(#FF5252, 85)
// ═══════════════════════════════════════════════════════════════════════════════
// DATE FILTER LOGIC
// ═══════════════════════════════════════════════════════════════════════════════
adjustedEndDate = endDate + 86399999
inDateRange = not useDateFilter or (time >= startDate and time <= adjustedEndDate)
// ═══════════════════════════════════════════════════════════════════════════════
// TIME & SESSION FUNCTIONS
// ═══════════════════════════════════════════════════════════════════════════════
nyHour = hour(time, "America/New_York")
nyMinute = minute(time, "America/New_York")
inOpeningRange = inDateRange and (nyHour == 9 and nyMinute >= 30 and nyMinute < 30 + orbMinutes)
isFirstORBar = inOpeningRange and not inOpeningRange[1]
orbEnded = not inOpeningRange and inOpeningRange[1] and inDateRange
forceExitEnabled = forceExitHour != 0
withinExitTime = not forceExitEnabled or nyHour < forceExitHour
inTradingHours = inDateRange and nyHour >= 9 and nyHour < tradingEnd and withinExitTime and not inOpeningRange
newDay = ta.change(time("D")) != 0
isForceExit = forceExitEnabled and nyHour >= forceExitHour
isSessionEnd = nyHour == 15 and nyMinute >= 45
// ═══════════════════════════════════════════════════════════════════════════════
// OPENING RANGE TRACKING
// ═══════════════════════════════════════════════════════════════════════════════
var float orHigh = na
var float orLow = na
var float orMid = na
var int orStartBar = na
var int orEndBar = na
var bool orComplete = false
var bool brokenUp = false
var bool brokenDown = false
if newDay
orHigh := na
orLow := na
orMid := na
orStartBar := na
orEndBar := na
orComplete := false
brokenUp := false
brokenDown := false
if inOpeningRange
if isFirstORBar
orHigh := high
orLow := low
orStartBar := bar_index
else
orHigh := math.max(orHigh, high)
orLow := math.min(orLow, low)
if orbEnded and not orComplete
orComplete := true
orMid := (orHigh + orLow) / 2
orEndBar := bar_index
orRange = orComplete ? orHigh - orLow : na
atr = ta.atr(14)
// ═══════════════════════════════════════════════════════════════════════════════
// FVG DETECTION
// ═══════════════════════════════════════════════════════════════════════════════
type FVG
float top
float bottom
bool bullish
int bar
bool filled
var array<FVG> fvgArray = array.new<FVG>()
minFVGSize = atr * 0.3
bullishFVG = inDateRange and low > high[2] and (low - high[2]) > minFVGSize
bearishFVG = inDateRange and high < low[2] and (low[2] - high) > minFVGSize
if bullishFVG
fvg = FVG.new()
fvg.top := low
fvg.bottom := high[2]
fvg.bullish := true
fvg.bar := bar_index - 1
fvg.filled := false
if array.size(fvgArray) >= 20
array.shift(fvgArray)
array.push(fvgArray, fvg)
if bearishFVG
fvg = FVG.new()
fvg.top := low[2]
fvg.bottom := high
fvg.bullish := false
fvg.bar := bar_index - 1
fvg.filled := false
if array.size(fvgArray) >= 20
array.shift(fvgArray)
array.push(fvgArray, fvg)
if array.size(fvgArray) > 0 and inDateRange
for i = array.size(fvgArray) - 1 to 0
if i < array.size(fvgArray)
fvg = array.get(fvgArray, i)
if not fvg.filled
fvgMid = (fvg.top + fvg.bottom) / 2
if fvg.bullish and low <= fvgMid
fvg.filled := true
if not fvg.bullish and high >= fvgMid
fvg.filled := true
f_hasFVGConfluence(bool forLong) =>
hasConfluence = false
if array.size(fvgArray) > 0
for i = array.size(fvgArray) - 1 to 0
if i < array.size(fvgArray)
fvg = array.get(fvgArray, i)
if not fvg.filled and bar_index - fvg.bar < 100
if forLong and fvg.bullish
hasConfluence := true
break
if not forLong and not fvg.bullish
hasConfluence := true
break
hasConfluence
bullishFVGPresent = f_hasFVGConfluence(true)
bearishFVGPresent = f_hasFVGConfluence(false)
// ═══════════════════════════════════════════════════════════════════════════════
// DAILY DIRECTION LOGIC (c1 = Today, c2 = Yesterday, c3 = Day Before)
// ═══════════════════════════════════════════════════════════════════════════════
// Fetch Daily Data (c2 = [1], c3 = [2])
[d_close1, d_close2, d_low1, d_low2, d_high1, d_high2] = request.security(syminfo.tickerid, "D", [close[1], close[2], low[1], low[2], high[1], high[2]])
// Bullish Conditions for Today
bullishCondA = d_close1 > d_close2 // c2 closed above c3
bullishCondB = (d_low1 < d_low2) and (d_close1 > d_low2) // c2 swept c3 low, closed above c3 low
isDailyBullish = bullishCondA or bullishCondB
// Bearish Conditions for Today
bearishCondA = d_close1 < d_close2 // c2 closed below c3
bearishCondB = (d_high1 > d_high2) and (d_close1 < d_high2) // c2 swept c3 high, closed below c3 high
isDailyBearish = bearishCondA or bearishCondB
// Apply to Filter
dailyDirOkLong = not useDailyDir or isDailyBullish
dailyDirOkShort = not useDailyDir or isDailyBearish
// ═══════════════════════════════════════════════════════════════════════════════
// SIGNALS & FILTER LOGIC
// ═══════════════════════════════════════════════════════════════════════════════
// Trend Logic
trendEMA = ta.ema(close, trendLen)
trendOkLong = not useTrendFilter or close > trendEMA
trendOkShort = not useTrendFilter or close < trendEMA
// Plot Trend
plot(showTrend and useTrendFilter ? trendEMA : na, "Trend EMA", color=color.new(color.gray, 50))
avgVol = ta.sma(volume, 20)
highVolume = volume > avgVol * 1.2
volumeOK = not requireVolume or highVolume
breakoutUp = inDateRange and orComplete and not brokenUp and close > orHigh and close[1] <= orHigh
breakoutDown = inDateRange and orComplete and not brokenDown and close < orLow and close[1] >= orLow
if breakoutUp
brokenUp := true
if breakoutDown
brokenDown := true
// Retest Logic
var bool waitingForLongRetest = false
var bool waitingForShortRetest = false
if breakoutUp and entryType == "Retest"
waitingForLongRetest := true
if breakoutDown and entryType == "Retest"
waitingForShortRetest := true
longRetest = waitingForLongRetest and low <= orHigh and close > orHigh
shortRetest = waitingForShortRetest and high >= orLow and close < orLow
if longRetest
waitingForLongRetest := false
if shortRetest
waitingForShortRetest := false
if waitingForLongRetest and close < orMid
waitingForLongRetest := false
if waitingForShortRetest and close > orMid
waitingForShortRetest := false
// HELPER: CALCULATE THEORETICAL STOP LOSS TO CHECK FILTER
f_calcSL(bool isLong, float price) =>
sl = 0.0
if isLong
if slType == "Opposite Side"
sl := orLow - atr * 0.1
else if slType == "Midpoint"
sl := orMid - atr * 0.1
else
sl := price - atr * 1.5
else
if slType == "Opposite Side"
sl := orHigh + atr * 0.1
else if slType == "Midpoint"
sl := orMid + atr * 0.1
else
sl := price + atr * 1.5
sl
// Generate Signals
var int lastSignalBar = 0
var bool tradedLongToday = false
var bool tradedShortToday = false
if newDay
tradedLongToday := false
tradedShortToday := false
fvgOKLong = not requireFVG or bullishFVGPresent
fvgOKShort = not requireFVG or bearishFVGPresent
validTiming = inTradingHours and bar_index - lastSignalBar >= 5
// --- APPLY RANGE FILTER ---
tempSLLong = f_calcSL(true, close)
tempRiskLong = math.abs(close - tempSLLong)
rangeOKLong = not useRangeFilter or (tempRiskLong <= maxRiskPoints)
tempSLShort = f_calcSL(false, close)
tempRiskShort = math.abs(tempSLShort - close)
rangeOKShort = not useRangeFilter or (tempRiskShort <= maxRiskPoints)
// --- COMBINE ALL FILTERS INCLUDING TREND & DAILY DIR ---
longEntry = false
if entryType == "Breakout"
longEntry := breakoutUp and volumeOK and fvgOKLong and validTiming and not tradedLongToday and rangeOKLong and trendOkLong and dailyDirOkLong
else
longEntry := longRetest and volumeOK and fvgOKLong and validTiming and not tradedLongToday and rangeOKLong and trendOkLong and dailyDirOkLong
shortEntry = false
if entryType == "Breakout"
shortEntry := breakoutDown and volumeOK and fvgOKShort and validTiming and not tradedShortToday and rangeOKShort and trendOkShort and dailyDirOkShort
else
shortEntry := shortRetest and volumeOK and fvgOKShort and validTiming and not tradedShortToday and rangeOKShort and trendOkShort and dailyDirOkShort
buySignal = showSignals and longEntry
sellSignal = showSignals and shortEntry
if buySignal
lastSignalBar := bar_index
tradedLongToday := true
if sellSignal
lastSignalBar := bar_index
tradedShortToday := true
// ═══════════════════════════════════════════════════════════════════════════════
// STOP LOSS & TAKE PROFIT CALCULATION
// ═══════════════════════════════════════════════════════════════════════════════
var float entryPrice = na
var float stopLoss = na
var float takeProfit = na
if buySignal and orComplete
entryPrice := close
stopLoss := f_calcSL(true, entryPrice)
riskAmt = entryPrice - stopLoss
takeProfit := entryPrice + (riskAmt * rrRatio)
if sellSignal and orComplete
entryPrice := close
stopLoss := f_calcSL(false, entryPrice)
riskAmt = stopLoss - entryPrice
takeProfit := entryPrice - (riskAmt * rrRatio)
// ═══════════════════════════════════════════════════════════════════════════════
// PERFORMANCE & VISUALIZATION
// ═══════════════════════════════════════════════════════════════════════════════
type TradeRecord
float entry
float sl
float tp
bool isLong
int bar
bool closed
bool won
float riskSize
label tradeLabel // Store label ID here
var array<TradeRecord> trades = array.new<TradeRecord>()
var array<bool> results = array.new<bool>()
var float winRate = 0.0
var int totalWins = 0
var int totalLosses = 0
var float totalRCaptured = 0.0
var float currentLossStreak = 0.0
var float maxDrawdown = 0.0
var array<float> winRanges = array.new<float>()
var array<float> lossRanges = array.new<float>()
// 1. CREATE TRADE & DRAW LABEL IMMEDIATELY
if buySignal or sellSignal
// --- DRAW VISUALS ---
label createdLabel = na
if buySignal
labelText = "🎯 LONG\nORB Break"
if requireFVG and bullishFVGPresent
labelText := labelText + "\n+FVG ✓"
createdLabel := label.new(bar_index, low - atr * 0.5, text=labelText, style=label.style_label_up, color=color.new(bullColor, 20), textcolor=color.white, size=size.normal)
line.new(bar_index, stopLoss, bar_index + 30, stopLoss, color=color.new(bearColor, 50), width=1, style=line.style_dashed)
line.new(bar_index, takeProfit, bar_index + 30, takeProfit, color=color.new(bullColor, 50), width=1, style=line.style_dashed)
else
labelText = "🎯 SHORT\nORB Break"
if requireFVG and bearishFVGPresent
labelText := labelText + "\n+FVG ✓"
createdLabel := label.new(bar_index, high + atr * 0.5, text=labelText, style=label.style_label_down, color=color.new(bearColor, 20), textcolor=color.white, size=size.normal)
line.new(bar_index, stopLoss, bar_index + 30, stopLoss, color=color.new(bearColor, 50), width=1, style=line.style_dashed)
line.new(bar_index, takeProfit, bar_index + 30, takeProfit, color=color.new(bullColor, 50), width=1, style=line.style_dashed)
// --- STORE TRADE ---
t = TradeRecord.new()
t.entry := entryPrice
t.sl := stopLoss
t.tp := takeProfit
t.isLong := buySignal
t.bar := bar_index
t.closed := false
t.won := false
t.riskSize := math.abs(entryPrice - stopLoss)
t.tradeLabel := createdLabel // Save the label to the trade
if array.size(trades) >= 50
array.shift(trades)
array.push(trades, t)
// 2. CHECK FOR EXITS & UPDATE LABEL
if array.size(trades) > 0
for i = array.size(trades) - 1 to 0
if i < array.size(trades)
t = array.get(trades, i)
if not t.closed and bar_index > t.bar
float currentR = 0.0
if t.isLong
risk = t.entry - t.sl
if low <= t.sl
t.closed := true
t.won := false
currentR := -1.0
else if high >= t.tp
t.closed := true
t.won := true
currentR := rrRatio
else if isSessionEnd or isForceExit or (bar_index - t.bar > 80)
t.closed := true
t.won := close > t.entry
currentR := (close - t.entry) / risk
else // SHORT
risk = t.sl - t.entry
if high >= t.sl
t.closed := true
t.won := false
currentR := -1.0
else if low <= t.tp
t.closed := true
t.won := true
currentR := rrRatio
else if isSessionEnd or isForceExit or (bar_index - t.bar > 80)
t.closed := true
t.won := close < t.entry
currentR := (t.entry - close) / risk
if t.closed
// --- UPDATE THE LABEL WITH RESULT AND R-MULTIPLE ---
rString = str.tostring(currentR, "#.##") + "R"
resultText = t.won ? ("\n✅ WIN " + rString) : ("\n❌ LOSS " + rString)
if isForceExit
resultText := resultText + "\n(TIME EXIT)"
currentText = label.get_text(t.tradeLabel)
label.set_text(t.tradeLabel, currentText + resultText)
label.set_color(t.tradeLabel, t.won ? color.new(bullColor, 0) : color.new(bearColor, 0))
totalRCaptured := totalRCaptured + currentR
if t.won
array.push(winRanges, t.riskSize)
totalWins := totalWins + 1
else
array.push(lossRanges, t.riskSize)
totalLosses := totalLosses + 1
if currentR < 0
currentLossStreak := currentLossStreak + currentR
else
currentLossStreak := 0.0
if currentLossStreak < maxDrawdown
maxDrawdown := currentLossStreak
if array.size(results) >= 50
array.shift(results)
array.push(results, t.won)
// Calculate Win Rate
if array.size(results) > 0
wins = 0
for i = 0 to array.size(results) - 1
if array.get(results, i)
wins := wins + 1
winRate := (wins / array.size(results)) * 100
if array.size(trades) > 0
for i = array.size(trades) - 1 to 0
if i < array.size(trades)
t = array.get(trades, i)
if t.closed
array.remove(trades, i)
// ═══════════════════════════════════════════════════════════════════════════════
// BOX VISUALIZATION (ORB & FVG)
// ═══════════════════════════════════════════════════════════════════════════════
var box orBox = na
if showORBox and orComplete and not na(orStartBar) and inDateRange
box.delete(orBox)
orBox := box.new(orStartBar, orHigh, bar_index + 20, orLow, border_color=orbColor, border_width=2, bgcolor=color.new(orbColor, 90))
var line orHighLine = na
var line orLowLine = na
var line orMidLine = na
if orComplete and inDateRange
line.delete(orHighLine)
line.delete(orLowLine)
line.delete(orMidLine)
orHighLine := line.new(orEndBar, orHigh, bar_index + 50, orHigh, color=bullColor, style=line.style_solid, width=2)
orLowLine := line.new(orEndBar, orLow, bar_index + 50, orLow, color=bearColor, style=line.style_solid, width=2)
orMidLine := line.new(orEndBar, orMid, bar_index + 50, orMid, color=color.gray, style=line.style_dotted, width=1)
if showFVG and array.size(fvgArray) > 0 and inDateRange
for i = math.max(0, array.size(fvgArray) - 5) to array.size(fvgArray) - 1
fvg = array.get(fvgArray, i)
if not fvg.filled and bar_index - fvg.bar < 50
fvgCol = fvg.bullish ? fvgBullColor : fvgBearColor
box.new(fvg.bar, fvg.top, bar_index + 10, fvg.bottom, border_color=na, bgcolor=fvgCol)
// ═══════════════════════════════════════════════════════════════════════════════
// DASHBOARD 1: GENERAL STATS
// ═══════════════════════════════════════════════════════════════════════════════
if showDashboard and barstate.islast
orbStatus = orComplete ? "✅ COMPLETE" : inOpeningRange ? "⏳ FORMING" : "❌ WAITING"
breakStatus = brokenUp ? "🟢 LONG" : brokenDown ? "🔴 SHORT" : "⚪ NONE"
fvgStatus = bullishFVGPresent ? "🟢 BULL" : bearishFVGPresent ? "🔴 BEAR" : "⚪ NONE"
rangeText = orComplete ? str.tostring(orRange, "#.##") : "--"
dashText = "══ NTrades ORB ══\n"
dashText := dashText + "TF: " + timeframe.period + "\n"
dashText := dashText + "───────────────────\n"
if orComplete
dashText := dashText + "Range: " + rangeText + "\n"
dashText := dashText + "Breakout: " + breakStatus + "\n"
dashText := dashText + "FVG: " + fvgStatus + "\n"
dashText := dashText + "───────────────────\n"
if useDailyDir
dirStatus = isDailyBullish and isDailyBearish ? "🟡 CHOP" : isDailyBullish ? "🟢 BULL" : isDailyBearish ? "🔴 BEAR" : "⚪ NONE"
dashText := dashText + "🧭 Daily Bias: " + dirStatus + "\n"
if useRangeFilter
dashText := dashText + "🔍 Risk Filter: <" + str.tostring(maxRiskPoints) + "\n"
if useTrendFilter
dashText := dashText + "🌊 Trend Filter: ON (" + str.tostring(trendLen) + ")\n"
if array.size(results) > 0
dashText := dashText + "📈 Win Rate: " + str.tostring(winRate, "#.#") + "%\n"
rColor = totalRCaptured >= 0 ? "🟢" : "🔴"
dashText := dashText + "💰 Total R: " + rColor + " " + str.tostring(totalRCaptured, "#.##") + "R\n"
dashText := dashText + "📉 Max DD: " + str.tostring(maxDrawdown, "#.##") + "R\n"
dashText := dashText + "W/L: " + str.tostring(totalWins) + "/" + str.tostring(totalLosses) + "\n"
else
dashText := dashText + "📈 No trades in range\n"
dashText := dashText + "═══════════════════"
var table dashboard = table.new(position.top_right, 1, 1, bgcolor=color.new(color.black, 85))
table.cell(dashboard, 0, 0, text=dashText, text_color=color.black, text_size=size.small)
// ═══════════════════════════════════════════════════════════════════════════════
// DASHBOARD 2: RISK RANGE ANALYTICS
// ═══════════════════════════════════════════════════════════════════════════════
if showStatsPanel and barstate.islast
// Calculate Stats for Winners
float w_avg = 0.0
float w_max = 0.0
float w_min = 999999.0
if array.size(winRanges) > 0
w_max := array.max(winRanges)
w_min := array.min(winRanges)
w_avg := array.avg(winRanges)
else
w_min := 0.0
// Calculate Stats for Losers
float l_avg = 0.0
float l_max = 0.0
float l_min = 999999.0
if array.size(lossRanges) > 0
l_max := array.max(lossRanges)
l_min := array.min(lossRanges)
l_avg := array.avg(lossRanges)
else
l_min := 0.0
// Build Table
var table statsTable = table.new(position.bottom_right, 3, 4, bgcolor=color.new(color.black, 85), border_width=1, frame_color=color.gray)
// Header
table.cell(statsTable, 0, 0, "1R Range Stats", text_color=color.white, bgcolor=color.gray)
table.cell(statsTable, 1, 0, "Winners 🟢", text_color=color.white, bgcolor=color.gray)
table.cell(statsTable, 2, 0, "Losers 🔴", text_color=color.white, bgcolor=color.gray)
// Average
table.cell(statsTable, 0, 1, "Avg Range", text_color=color.rgb(0, 0, 0))
table.cell(statsTable, 1, 1, str.tostring(w_avg, "#.##"), text_color=bullColor)
table.cell(statsTable, 2, 1, str.tostring(l_avg, "#.##"), text_color=bearColor)
// Max
table.cell(statsTable, 0, 2, "Max Range", text_color=color.rgb(0, 0, 0))
table.cell(statsTable, 1, 2, str.tostring(w_max, "#.##"), text_color=bullColor)
table.cell(statsTable, 2, 2, str.tostring(l_max, "#.##"), text_color=bearColor)
// Min
table.cell(statsTable, 0, 3, "Min Range", text_color=color.rgb(0, 0, 0))
table.cell(statsTable, 1, 3, str.tostring(w_min, "#.##"), text_color=bullColor)
table.cell(statsTable, 2, 3, str.tostring(l_min, "#.##"), text_color=bearColor)
// ═══════════════════════════════════════════════════════════════════════════════
// ALERTS
// ═══════════════════════════════════════════════════════════════════════════════
alertcondition(orComplete and not orComplete[1], title="Opening Range Complete", message="ORB Complete")
alertcondition(buySignal, title="ORB Long Signal", message="ORB LONG Breakout Signal!")
alertcondition(sellSignal, title="ORB Short Signal", message="ORB SHORT Breakout Signal!")