本页源码来自 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/
// © AuraSznfx
//@version=6
// ORB Map: Opening Range Breakout + Midline Zones [Aurabot]
// The opening range (first 15 minutes after the 9:30 ET open by default) drawn as zones:
// the range itself, its midline, and "typical run" / "big day" extension zones above and below.
// A plain-words read of where price is (above / below the midline, broke out, failed breakout),
// watch tags for break-and-retest, failed breaks, the three-bar pattern and midline chop,
// a check against a second market (ES vs NQ), fixed-dollar risk sizing, and stats from your own chart history.
// 4-year test (Dec 2021 to 2026, NQ / ES / Gold): breaks that ES and NQ agree on stayed past the midline 48% of the time
// vs 27% when they disagreed, and price finished the morning on the break side of the midline about 70% of the time.
// Watch tags are places to look, not signals. Educational tool, not trade signals or financial advice.
indicator("ORB Map: Opening Range Breakout + Midline Zones [Aurabot]", "AURΔBØT · ORB Map", overlay = true, max_lines_count = 300, max_labels_count = 300, max_boxes_count = 200, max_bars_back = 3000)
TZ = "America/New_York"
// ───────────────────────── ① What to show ─────────────────────────
g1 = "① What to show"
showZone = input.bool(true, "Opening range zone", group = g1, tooltip = "Shaded box from the opening range high to its low.", display = display.none)
showMid = input.bool(true, "Midline", group = g1, tooltip = "Halfway between the opening range high and low. Above it the morning leans up, below it the morning leans down.", display = display.none)
showExt = input.bool(true, "Run zones", group = g1, tooltip = "Zones above and below the range where breakouts usually run to. Typical run = 0.8x to 1.0x the range size past the edge. Big day = 1.5x to 2.0x. On 4 years of NQ the median run past the edge was about 0.9x the range.", display = display.none)
showRT = input.bool(true, "Break and retest tag", group = g1, tooltip = "After a close outside the range, price comes back to the edge and holds. Shows a small risk box from the retest to just inside the range.", display = display.none)
showFail = input.bool(true, "Failed break tag", group = g1, tooltip = "Price broke out, then closed back through the midline. On 4 years of data, failed breaks went on to reach the other side of the range 62 to 70% of the time.", display = display.none)
show3B = input.bool(true, "Three-bar tag", group = g1, tooltip = "A strong candle, a small pause candle, then another strong candle the same way, after the range is set.", display = display.none)
showChop = input.bool(true, "Chop warning", group = g1, tooltip = "Price crossed the midline 3 or more times in the last 12 candles. Breakouts and retests work worse in chop.", display = display.none)
showPanel = input.bool(true, "Show the panel", group = g1, tooltip = "The read for today, the second market check, risk and your chart's own ORB stats.", display = display.none)
// ───────────────────────── ② Colors ─────────────────────────
g2 = "② Colors"
themeChoice = input.string("Aurabot", "Color Theme", group = g2, options = ["Aurabot", "Neon Cyber", "Midnight Aura", "Sunset Blaze", "Ocean Depth", "Ghost Protocol", "Classic", "Neon Violet", "Plasma", "Blade Runner", "Toxic", "Ghost Wire", "Midnight Blue", "Ember Gold", "Stealth Dark", "Clean Light", "Custom"], tooltip = "Sets every color at once. Pick Custom to use your own colors below.", display = display.none)
cuHigh = input.color(#FF427E, "Sell side (Custom)", group = g2, tooltip = "Only used when Color Theme is Custom.", display = display.none)
cuLow = input.color(#00D9FF, "Buy side (Custom)", group = g2, tooltip = "Only used when Color Theme is Custom.", display = display.none)
cuAccent = input.color(#FACC15, "Accent (Custom)", group = g2, tooltip = "Only used when Color Theme is Custom.", display = display.none)
cuNeutral = input.color(#8A8AA0, "Neutral (Custom)", group = g2, tooltip = "Only used when Color Theme is Custom.", display = display.none)
midSide = input.bool(true, "Midline by price side", group = g2, tooltip = "On: the midline turns the buy side color when price is above it and the sell side color when price is below it.", display = display.none)
// ───────────────────────── ③ Lines and zones ─────────────────────────
g3 = "③ Lines and zones"
edgeStyleIn = input.string("Solid", "High / low line", options = ["Solid", "Dashed", "Dotted"], group = g3, tooltip = "Style of the opening range high and low lines.", display = display.none)
edgeWidth = input.int(2, "↳ Width", 1, 10, group = g3, display = display.none)
midStyleIn = input.string("Dashed", "Midline", options = ["Solid", "Dashed", "Dotted"], group = g3, tooltip = "Style of the midline.", display = display.none)
midWidth = input.int(2, "↳ Width", 1, 10, group = g3, display = display.none)
zoneFill = input.int(88, "Range zone see-through %", 0, 100, group = g3, tooltip = "100 = invisible, 0 = solid.", display = display.none)
extFill = input.int(90, "Run zones see-through %", 0, 100, group = g3, tooltip = "100 = invisible, 0 = solid.", display = display.none)
// ───────────────────────── ④ Labels ─────────────────────────
g4 = "④ Labels"
showNames = input.bool(true, "Show names", group = g4, tooltip = "ORB HIGH, ORB LOW, MIDLINE and the zone names.", display = display.none)
showPx = input.bool(true, "Show prices", group = g4, tooltip = "Price next to each name.", display = display.none)
lblSize = input.string("Small", "Text size", options = ["Tiny", "Small", "Normal"], group = g4, display = display.none)
// ───────────────────────── ⑤ Panel ─────────────────────────
g5 = "⑤ Panel"
panelPos = input.string("Bottom right", "Panel position", options = ["Top right", "Bottom right", "Bottom left", "Top left"], group = g5, display = display.none)
riskUSD = input.float(200, "Risk per trade ($)", minval = 10, group = g5, tooltip = "Dollars you are willing to lose on one trade. Used for the size on the retest risk box.", display = display.none)
pvIn = input.float(0, "$ per point (0 = auto)", minval = 0, group = g5, tooltip = "Automatic knows NQ, MNQ, ES, MES, YM, MYM, RTY, M2K, GC, MGC, SI, CL, MCL.", display = display.none)
// ───────────────────────── ⑥ Advanced ─────────────────────────
g6 = "⑥ Advanced"
openHM = input.string("0930", "Open time (NY)", group = g6, tooltip = "When the opening range starts, New York time, HHMM.", display = display.none)
orbMins = input.int(15, "Range length (minutes)", options = [5, 10, 15, 30, 60], group = g6, tooltip = "15 = the classic 15-minute opening range.", display = display.none)
cutHM = input.string("1200", "Lines end at (NY)", group = g6, tooltip = "Zones and tags stop at this time, HHMM. 1200 = noon.", display = display.none)
compIn = input.string("Auto", "Compare with", group = g6, tooltip = "Second market for the in sync check. Auto: ES for NQ, NQ for ES (minis and micros). Type a symbol like CME_MINI:ES1! or None to turn it off.", display = display.none)
statDays = input.int(60, "Stats: days to look back", 10, 250, group = g6, tooltip = "How many past sessions on your chart feed the stats in the panel. Needs that many days loaded on the chart.", display = display.none)
keepDays = input.int(0, "Past days to show", 0, 10, group = g6, tooltip = "0 keeps only today's map. Raise it to review earlier days.", display = display.none)
// ───────────────────────── Theme colors ─────────────────────────
cSell = switch themeChoice
"Aurabot" => #FF427E
"Neon Cyber" => #FF1744
"Midnight Aura" => #F472B6
"Sunset Blaze" => #EF4444
"Ocean Depth" => #F97316
"Ghost Protocol" => #52525B
"Classic" => #F23645
"Neon Violet" => #FF4081
"Plasma" => #FF006E
"Blade Runner" => #448AFF
"Toxic" => #D500F9
"Ghost Wire" => #FF8A80
"Midnight Blue" => #FF6B6B
"Ember Gold" => #FF6E40
"Stealth Dark" => #EF9A9A
"Clean Light" => #C62828
=> cuHigh
cBuy = switch themeChoice
"Aurabot" => #00D9FF
"Neon Cyber" => #00E676
"Midnight Aura" => #6366F1
"Sunset Blaze" => #FBBF24
"Ocean Depth" => #22D3EE
"Ghost Protocol" => #A1A1AA
"Classic" => #089981
"Neon Violet" => #B388FF
"Plasma" => #00FFF5
"Blade Runner" => #FFAB40
"Toxic" => #76FF03
"Ghost Wire" => #84FFFF
"Midnight Blue" => #00B0FF
"Ember Gold" => #FFD740
"Stealth Dark" => #A5D6A7
"Clean Light" => #2E7D32
=> cuLow
cKey = switch themeChoice
"Aurabot" => #FACC15
"Neon Cyber" => #FFEA00
"Midnight Aura" => #A78BFA
"Sunset Blaze" => #FB923C
"Ocean Depth" => #38BDF8
"Ghost Protocol" => #D4D4D8
"Classic" => #FF9800
"Neon Violet" => #E040FB
"Plasma" => #FFD60A
"Blade Runner" => #FF6E40
"Toxic" => #C6FF00
"Ghost Wire" => #EEFF41
"Midnight Blue" => #FFD166
"Ember Gold" => #FFAB00
"Stealth Dark" => #FFE082
"Clean Light" => #EF6C00
=> cuAccent
cNeutral = switch themeChoice
"Aurabot" => #8A8AA0
"Neon Cyber" => #78909C
"Midnight Aura" => #64748B
"Sunset Blaze" => #9A8478
"Ocean Depth" => #64748B
"Ghost Protocol" => #71717A
"Classic" => #787B86
"Neon Violet" => #8D8FA6
"Plasma" => #5C6B73
"Blade Runner" => #607D8B
"Toxic" => #7A8B6F
"Ghost Wire" => #78909C
"Midnight Blue" => #546E7A
"Ember Gold" => #8D6E63
"Stealth Dark" => #6D7B6E
"Clean Light" => #90A4AE
=> cuNeutral
isLight = themeChoice == "Clean Light"
cText = isLight ? #263238 : #EDE9FE
cPanel = isLight ? color.new(#FFFFFF, 5) : color.new(#07060B, 8)
txtSz = lblSize == "Tiny" ? size.tiny : lblSize == "Normal" ? size.normal : size.small
styleOf(string s) => s == "Dashed" ? line.style_dashed : s == "Dotted" ? line.style_dotted : line.style_solid
edgeStyle = styleOf(edgeStyleIn)
midStyle = styleOf(midStyleIn)
// ───────────────────────── Time ─────────────────────────
hmToMin(string s) => int(str.tonumber(str.substring(s, 0, 2))) * 60 + int(str.tonumber(str.substring(s, 2, 4)))
nowMin = hour(time, TZ) * 60 + minute(time, TZ)
openMin = hmToMin(openHM)
endMin = openMin + orbMins
cutMin = hmToMin(cutHM)
inORB = nowMin >= openMin and nowMin < endMin
orbStart = inORB and not (inORB[1] and dayofmonth(time, TZ) == dayofmonth(time[1], TZ))
orbDone = nowMin >= endMin and nowMin < cutMin
orbJustDone = orbDone and not orbDone[1] and dayofmonth(time, TZ) == dayofmonth(time[1], TZ)
pastCut = nowMin >= cutMin and orbDone[1]
tfOK = timeframe.isintraday and timeframe.in_seconds() <= orbMins * 60
barMs = time - nz(time[1], time)
// ───────────────────────── $ per point ─────────────────────────
root = syminfo.root
autoPV = root == "NQ" ? 20.0 : root == "MNQ" ? 2.0 : root == "ES" ? 50.0 : root == "MES" ? 5.0 : root == "YM" ? 5.0 : root == "MYM" ? 0.5 : root == "RTY" ? 50.0 : root == "M2K" ? 5.0 : root == "GC" ? 100.0 : root == "MGC" ? 10.0 : root == "SI" ? 5000.0 : root == "CL" ? 1000.0 : root == "MCL" ? 100.0 : syminfo.pointvalue
pv = pvIn > 0 ? pvIn : autoPV
// ───────────────────────── Second market ─────────────────────────
compSym = compIn == "None" ? "" : compIn != "Auto" ? compIn : root == "NQ" ? "CME_MINI:ES1!" : root == "MNQ" ? "CME_MINI:MES1!" : root == "ES" ? "CME_MINI:NQ1!" : root == "MES" ? "CME_MINI:MNQ1!" : ""
compOn = compSym != ""
[cH, cL, cC] = request.security(compOn ? compSym : syminfo.tickerid, timeframe.period, [high, low, close], lookahead = barmerge.lookahead_off)
compName = compOn ? str.replace(str.replace(compSym, "CME_MINI:", ""), "1!", "") : ""
// ───────────────────────── Today's range state ─────────────────────────
var float oH = na
var float oL = na
var float cmpH = na
var float cmpL = na
var float cmpOpen = na
var int tStart = 0
var int brk = 0 // +1 broke up, -1 broke down, 0 not yet
var int cmpBrk = 0
var bool failed = false
var bool rtDone = false
var bool failTagged = false
var float maxRun = 0.0
var int crosses = 0
var int lastSide = 0
var array<int> crossBars = array.new<int>()
// drawings
var box zBox = na
var box zUp1 = na
var box zUp2 = na
var box zDn1 = na
var box zDn2 = na
var line lHi = na
var line lLo = na
var line lMid = na
var label tHi = na
var label tLo = na
var label tMid = na
var label tU1 = na
var label tU2 = na
var label tD1 = na
var label tD2 = na
var array<box> oldBoxes = array.new<box>()
var array<line> oldLines = array.new<line>()
var array<label> oldLabels = array.new<label>()
var array<int> oldDay = array.new<int>()
// stats from chart history (one entry per finished day that broke out)
var array<float> stHeld = array.new<float>() // 1 = stayed past the midline until the cut
var array<float> stSide = array.new<float>() // 1 = finished on the break side of the midline
var array<float> stRun = array.new<float>() // run past the edge in points
var array<float> stRunX = array.new<float>() // run past the edge / range size
var array<float> stFailX = array.new<float>() // 1 = failed break reached the other edge
var array<float> stRng = array.new<float>() // range sizes for "wide / normal / narrow"
var bool failReachedOther = false
var float closeAtCut = na
var int dayCount = 0
px(float p) => str.tostring(p, format.mintick)
nm(string n, float p) => showNames ? (n + (showPx ? " " + px(p) : "")) : ""
// close out yesterday: record stats, archive or delete drawings
if orbStart and tfOK
if not na(oH) and brk != 0
float m0 = (oH + oL) / 2
array.push(stHeld, failed ? 0.0 : 1.0)
array.push(stSide, (brk == 1 ? closeAtCut > m0 : closeAtCut < m0) ? 1.0 : 0.0)
array.push(stRun, maxRun)
array.push(stRunX, maxRun / math.max(oH - oL, syminfo.mintick))
if failed
array.push(stFailX, failReachedOther ? 1.0 : 0.0)
while array.size(stHeld) > statDays
array.shift(stHeld)
array.shift(stSide)
array.shift(stRun)
array.shift(stRunX)
while array.size(stFailX) > statDays
array.shift(stFailX)
dayCount += 1
for b in array.from(zBox, zUp1, zUp2, zDn1, zDn2)
if not na(b)
if keepDays > 0
array.push(oldBoxes, b)
else
box.delete(b)
for l in array.from(lHi, lLo, lMid)
if not na(l)
if keepDays > 0
array.push(oldLines, l)
else
line.delete(l)
for t in array.from(tHi, tLo, tMid, tU1, tU2, tD1, tD2)
if not na(t)
label.delete(t)
array.push(oldDay, dayCount)
while array.size(oldBoxes) > keepDays * 5
box.delete(array.shift(oldBoxes))
while array.size(oldLines) > keepDays * 3
line.delete(array.shift(oldLines))
while array.size(oldLabels) > keepDays * 12
label.delete(array.shift(oldLabels))
zBox := na
zUp1 := na
zUp2 := na
zDn1 := na
zDn2 := na
lHi := na
lLo := na
lMid := na
tHi := na
tLo := na
tMid := na
tU1 := na
tU2 := na
tD1 := na
tD2 := na
oH := high
oL := low
cmpH := cH
cmpL := cL
cmpOpen := nz(cC[1], cC)
tStart := time
brk := 0
cmpBrk := 0
failed := false
failReachedOther := false
rtDone := false
failTagged := false
maxRun := 0.0
crosses := 0
lastSide := 0
array.clear(crossBars)
else if inORB and tfOK and not na(oH)
oH := math.max(oH, high)
oL := math.min(oL, low)
cmpH := math.max(nz(cmpH, cH), cH)
cmpL := math.min(nz(cmpL, cL), cL)
rng = oH - oL
mid = (oH + oL) / 2
live = tfOK and orbDone and not na(oH)
tx = time + 3 * barMs
// range size vs the last 20 days
if orbJustDone and tfOK and not na(oH)
array.push(stRng, rng)
if array.size(stRng) > 21
array.shift(stRng)
avgRng = array.size(stRng) > 1 ? (array.sum(stRng) - rng) / (array.size(stRng) - 1) : na
rngWord = na(avgRng) ? "" : rng > 1.3 * avgRng ? "wide" : rng < 0.7 * avgRng ? "narrow" : "normal"
// draw the zones once the range is set
if orbJustDone and tfOK and not na(oH)
if showZone
zBox := box.new(tStart, oH, time, oL, xloc = xloc.bar_time, border_color = color.new(cNeutral, 60), bgcolor = color.new(cNeutral, zoneFill), border_width = 1)
lHi := line.new(tStart, oH, time, oH, xloc = xloc.bar_time, color = cSell, width = edgeWidth, style = edgeStyle)
lLo := line.new(tStart, oL, time, oL, xloc = xloc.bar_time, color = cBuy, width = edgeWidth, style = edgeStyle)
if showMid
lMid := line.new(tStart, mid, time, mid, xloc = xloc.bar_time, color = cKey, width = midWidth, style = midStyle)
if showExt
zUp1 := box.new(time, oH + 1.0 * rng, time, oH + 0.8 * rng, xloc = xloc.bar_time, border_color = color.new(cBuy, 75), bgcolor = color.new(cBuy, extFill), border_width = 1)
zUp2 := box.new(time, oH + 2.0 * rng, time, oH + 1.5 * rng, xloc = xloc.bar_time, border_color = color.new(cBuy, 82), bgcolor = color.new(cBuy, math.min(100, extFill + 4)), border_width = 1)
zDn1 := box.new(time, oL - 0.8 * rng, time, oL - 1.0 * rng, xloc = xloc.bar_time, border_color = color.new(cSell, 75), bgcolor = color.new(cSell, extFill), border_width = 1)
zDn2 := box.new(time, oL - 1.5 * rng, time, oL - 2.0 * rng, xloc = xloc.bar_time, border_color = color.new(cSell, 82), bgcolor = color.new(cSell, math.min(100, extFill + 4)), border_width = 1)
if showNames
tHi := label.new(tx, oH, nm("ORB HIGH", oH), xloc = xloc.bar_time, style = label.style_label_left, color = color.new(#000000, 100), textcolor = cSell, size = txtSz)
tLo := label.new(tx, oL, nm("ORB LOW", oL), xloc = xloc.bar_time, style = label.style_label_left, color = color.new(#000000, 100), textcolor = cBuy, size = txtSz)
if showMid
tMid := label.new(tx, mid, nm("MIDLINE", mid), xloc = xloc.bar_time, style = label.style_label_left, color = color.new(#000000, 100), textcolor = cKey, size = txtSz)
if showExt
tU1 := label.new(tx, oH + 0.9 * rng, "TYPICAL RUN", xloc = xloc.bar_time, style = label.style_label_left, color = color.new(#000000, 100), textcolor = color.new(cBuy, 20), size = txtSz)
tU2 := label.new(tx, oH + 1.75 * rng, "BIG DAY", xloc = xloc.bar_time, style = label.style_label_left, color = color.new(#000000, 100), textcolor = color.new(cBuy, 35), size = txtSz)
tD1 := label.new(tx, oL - 0.9 * rng, "TYPICAL RUN", xloc = xloc.bar_time, style = label.style_label_left, color = color.new(#000000, 100), textcolor = color.new(cSell, 20), size = txtSz)
tD2 := label.new(tx, oL - 1.75 * rng, "BIG DAY", xloc = xloc.bar_time, style = label.style_label_left, color = color.new(#000000, 100), textcolor = color.new(cSell, 35), size = txtSz)
// stretch everything to the latest candle while the morning is live
if live
box.set_right(zBox, tx)
for b in array.from(zUp1, zUp2, zDn1, zDn2)
box.set_right(b, tx)
line.set_x2(lHi, tx)
line.set_x2(lLo, tx)
line.set_x2(lMid, tx)
for t in array.from(tHi, tLo, tMid, tU1, tU2, tD1, tD2)
label.set_x(t, tx)
if midSide and not na(lMid)
line.set_color(lMid, close > mid ? cBuy : close < mid ? cSell : cKey)
label.set_textcolor(tMid, close > mid ? cBuy : close < mid ? cSell : cKey)
// ───────────────────────── The read ─────────────────────────
side = close > mid ? 1 : close < mid ? -1 : 0
newBreakUp = live and brk == 0 and close > oH
newBreakDown = live and brk == 0 and close < oL
if newBreakUp
brk := 1
if newBreakDown
brk := -1
if live and compOn and cmpBrk == 0
cmpBrk := cC > cmpH ? 1 : cC < cmpL ? -1 : 0
if live
closeAtCut := close
// run past the edge (for stats) and failed break
if live and brk != 0
maxRun := math.max(maxRun, brk == 1 ? high - oH : oL - low)
newFail = live and brk != 0 and not failed and (brk == 1 ? close < mid : close > mid)
if newFail
failed := true
if live and failed and not failReachedOther
failReachedOther := brk == 1 ? low <= oL : high >= oH
// midline chop: 3+ crosses in the last 12 candles
if live and side != 0
if lastSide != 0 and side != lastSide
array.push(crossBars, bar_index)
lastSide := side
while array.size(crossBars) > 0 and array.get(crossBars, 0) < bar_index - 12
array.shift(crossBars)
inChop = live and array.size(crossBars) >= 3
// break and retest: first time price comes back to the broken edge and closes back outside
var int brkBar = 0
if newBreakUp or newBreakDown
brkBar := bar_index
retestUp = live and brk == 1 and not failed and not rtDone and bar_index > brkBar and low <= oH + 0.1 * rng and close > oH
retestDown = live and brk == -1 and not failed and not rtDone and bar_index > brkBar and high >= oL - 0.1 * rng and close < oL
float rtStop = na
if retestUp or retestDown
rtDone := true
rtStop := retestUp ? oH - 0.25 * rng : oL + 0.25 * rng
// three-bar: strong, small pause, strong again the same way
body0 = math.abs(close - open)
body2 = math.abs(close[2] - open[2])
avgR = ta.sma(high - low, 20)
strong2 = body2 >= 0.6 * (high[2] - low[2]) and (high[2] - low[2]) >= avgR
pause1 = (high[1] - low[1]) <= 0.6 * (high[2] - low[2])
three = live and strong2 and pause1 and body0 >= 0.5 * (high - low) and math.sign(close - open) == math.sign(close[2] - open[2])
threeUp = three and close > open and close > high[1]
threeDn = three and close < open and close < low[1]
tagCol(int s) => s > 0 ? cBuy : cSell
if showRT and (retestUp or retestDown)
s = retestUp ? 1 : -1
float dist = math.abs(close - rtStop)
contracts = dist * pv > 0 ? math.floor(riskUSD / (dist * pv)) : 0
micros = dist * pv > 0 ? math.floor(riskUSD / (dist * pv / 10)) : 0
string sizeTxt = contracts >= 1 ? str.tostring(contracts) + " contract" + (contracts > 1 ? "s" : "") : micros >= 1 ? str.tostring(micros) + " micro" + (micros > 1 ? "s" : "") : "stop too wide for $" + str.tostring(riskUSD, "#")
array.push(oldLabels, label.new(time, retestUp ? low : high, "👀 RETEST HOLD", xloc = xloc.bar_time, style = retestUp ? label.style_label_up : label.style_label_down, color = color.new(tagCol(s), 15), textcolor = isLight ? #FFFFFF : #07060B, size = txtSz))
array.push(oldBoxes, box.new(time, retestUp ? close : rtStop, time + 6 * barMs, retestUp ? rtStop : close, xloc = xloc.bar_time, border_color = color.new(cSell, 50), bgcolor = color.new(cSell, 82), text = "RISK " + px(dist) + " pts · " + sizeTxt, text_color = cText, text_size = txtSz, text_halign = text.align_left))
if showFail and newFail and not failTagged
failTagged := true
s = brk == 1 ? -1 : 1
array.push(oldLabels, label.new(time, brk == 1 ? high : low, brk == 1 ? "⚠ FAILED BREAKOUT · leaning down" : "⚠ FAILED BREAKDOWN · leaning up", xloc = xloc.bar_time, style = brk == 1 ? label.style_label_down : label.style_label_up, color = color.new(tagCol(s), 15), textcolor = isLight ? #FFFFFF : #07060B, size = txtSz))
if show3B and (threeUp or threeDn)
array.push(oldLabels, label.new(time, threeUp ? low : high, "3-BAR", xloc = xloc.bar_time, style = threeUp ? label.style_label_up : label.style_label_down, color = color.new(#000000, 100), textcolor = tagCol(threeUp ? 1 : -1), size = txtSz))
chopStart = inChop and not inChop[1]
if showChop and chopStart
array.push(oldLabels, label.new(time, mid, "〰 CHOP · midline crossed 3x", xloc = xloc.bar_time, style = label.style_label_center, color = color.new(cNeutral, 30), textcolor = cText, size = size.tiny))
// ───────────────────────── Alerts ─────────────────────────
alertcondition(newBreakUp, "ORB high broken", "ORB Map: close above the opening range high on {{ticker}}")
alertcondition(newBreakDown, "ORB low broken", "ORB Map: close below the opening range low on {{ticker}}")
alertcondition(newFail, "Failed break", "ORB Map: the breakout failed and closed back through the midline on {{ticker}}")
alertcondition(retestUp or retestDown, "Retest hold", "ORB Map: price retested the broken ORB edge and held on {{ticker}}")
// ───────────────────────── Panel ─────────────────────────
pct(array<float> a) => array.size(a) > 0 ? str.tostring(math.round(array.avg(a) * 100)) + "%" : "n/a"
med(array<float> a) => array.size(a) > 0 ? array.median(a) : na
posOf(string p) => p == "Top right" ? position.top_right : p == "Bottom right" ? position.bottom_right : p == "Bottom left" ? position.bottom_left : position.top_left
var table tb = table.new(posOf(panelPos), 2, 9, bgcolor = cPanel, border_color = color.new(cNeutral, 70), border_width = 1, frame_color = cKey, frame_width = 1)
row(int r, string k, string v, color vc) =>
table.cell(tb, 0, r, k, text_color = color.new(cText, 35), text_size = size.small, text_halign = text.align_left)
table.cell(tb, 1, r, v, text_color = vc, text_size = size.small, text_halign = text.align_left)
if barstate.islast and showPanel
table.cell(tb, 0, 0, "ORB MAP", text_color = cKey, text_size = size.small, text_halign = text.align_left)
table.cell(tb, 1, 0, "[Aurabot] · " + str.tostring(orbMins) + "-min range", text_color = color.new(cText, 40), text_size = size.small, text_halign = text.align_left)
if not tfOK
row(1, "Heads up", "Use a chart of " + str.tostring(orbMins) + " minutes or less", cKey)
else if na(oH)
row(1, "Range", "Waiting for the " + openHM + " open", cText)
else
string rd = nowMin < endMin and nowMin >= openMin ? "Building · " + px(rng) + " pts so far" : px(rng) + " pts" + (rngWord != "" ? " · " + rngWord + " day" : "")
row(1, "Range", rd, cText)
string read = inORB ? "Too early, the range is still forming" : failed ? (brk == 1 ? "Failed breakout · leaning down" : "Failed breakdown · leaning up") : brk == 1 ? "Broke the high · uptrend morning" : brk == -1 ? "Broke the low · downtrend morning" : side == 1 ? "Inside, above the midline · leaning up" : side == -1 ? "Inside, below the midline · leaning down" : "Sitting on the midline"
color rc = failed ? (brk == 1 ? cSell : cBuy) : brk == 1 ? cBuy : brk == -1 ? cSell : side == 1 ? cBuy : side == -1 ? cSell : cText
row(2, "Read", read, rc)
if compOn
float cchg = nz(cmpOpen) > 0 ? (cC - cmpOpen) / cmpOpen * 100 : na
string cs = cmpBrk == 0 ? compName + " still inside its range" : brk == 0 ? compName + " broke " + (cmpBrk == 1 ? "up" : "down") + " first" : cmpBrk == brk ? "In sync · " + compName + " broke the same way" : "Diverging · " + compName + " broke the other way"
color cc = brk != 0 and cmpBrk != 0 ? (cmpBrk == brk ? cBuy : cSell) : cText
row(3, "vs " + compName, cs + (na(cchg) ? "" : " (" + (cchg >= 0 ? "+" : "") + str.tostring(cchg, "#.##") + "%)"), cc)
else
row(3, "vs other market", "Off (set Compare with)", color.new(cText, 50))
row(4, "Chop", inChop ? "Yes · midline crossed 3x lately" : "No", inChop ? cKey : color.new(cText, 40))
row(5, "Risk", "$" + str.tostring(riskUSD, "#") + " a trade · $" + str.tostring(pv, "#.##") + " a point", color.new(cText, 30))
row(6, "Your chart, last " + str.tostring(array.size(stHeld)) + " breaks", "Stayed past midline " + pct(stHeld) + " · ended on break side " + pct(stSide), cText)
row(7, "Typical run past edge", na(med(stRun)) ? "n/a" : px(med(stRun)) + " pts · " + str.tostring(med(stRunX), "#.#") + "x the range", cText)
row(8, "Failed breaks", "Reached the other side " + pct(stFailX) + " (" + str.tostring(array.size(stFailX)) + ")", cText)
else if barstate.islast
table.clear(tb, 0, 0, 1, 8)