本页源码来自 TradingView 公开发布的开源脚本,版权归原作者所有, 请遵循其原始许可(Pine 脚本常见 CC BY-NC-SA / MPL-2.0 / MIT)。 本项目仅用于研究检索与许可范围内的移植。
//@version=6
// ============================================================================
// Elliott Wave Three Launch Pyramid
// ----------------------------------------------------------------------------
// ============================================================================
indicator(title = "Elliott Wave Three Launch Pyramid", shorttitle = "EW3 Launch", overlay = true, max_labels_count = 500, max_lines_count = 300)
// ─────────────────────────────────────────────────────────────────────────
// INPUTS
// ─────────────────────────────────────────────────────────────────────────
gS = "Swing Structure"
pivLen = input.int(5, "Swing strength (bars)", minval = 2, maxval = 20, group = gS, tooltip = "Bars on each side needed to confirm a swing high or low. Higher values find larger waves but confirm them later; lower values react faster but create more noise.")
atrLen = input.int(14, "ATR length", minval = 5, maxval = 200, group = gS, tooltip = "ATR period used to size swings, breakout buffer and chase limit. Longer is smoother and slower to adapt; shorter adapts quickly to volatility changes.")
swingMin = input.float(1.5, "Min. swing size (x ATR)", minval = 0.5, maxval = 10.0, step = 0.1, group = gS, tooltip = "A swing against the previous one is accepted only if it is at least this many ATRs. Higher ignores small pullbacks; lower counts more, smaller swings.")
w1Min = input.float(3.0, "Min. wave 1 size (x ATR)", minval = 1.0, maxval = 20.0, step = 0.5, group = gS, tooltip = "Wave 1 must be at least this many ATRs long. Higher keeps only strong first waves and gives fewer signals; lower accepts weaker moves and more signals.")
r2Min = input.float(0.382, "Wave 2 min. retracement", minval = 0.1, maxval = 0.8, step = 0.01, group = gS, tooltip = "Smallest allowed wave 2 pullback as a fraction of wave 1. Higher demands a deeper correction before the setup arms; lower accepts shallow pauses.")
r2Max = input.float(0.786, "Wave 2 max. retracement", minval = 0.5, maxval = 0.99, step = 0.01, group = gS, tooltip = "Deepest allowed wave 2 pullback as a fraction of wave 1. Lower rejects deep, doubtful wave 2s; higher accepts setups closer to breaking rule 1.")
gE = "Entry"
side = input.string("Both", "Direction", options = ["Both", "Long only", "Short only"], group = gE, tooltip = "Which side may produce signals. Long only shows bullish wave 3 entries, Short only shows bearish ones, Both shows all.")
brkBuf = input.float(0.1, "Breakout buffer (x ATR)", minval = 0.0, maxval = 2.0, step = 0.05, group = gE, tooltip = "Close must exceed the end of wave 1 by this many ATRs. Higher avoids marginal false breaks but enters later; zero enters on any close beyond the level.")
setupLife = input.int(60, "Setup expiry (bars)", minval = 5, maxval = 500, group = gE, tooltip = "An armed wave 1-2 setup is cancelled if no breakout happens within this many bars. Lower keeps only fresh setups; higher waits longer for wave 3.")
gF = "Weakness Fixes"
fixConfirm = input.bool(true, "Signal on closed bars only", group = gF, tooltip = "FIX repaint: all logic runs only on confirmed bars, so a signal never appears and disappears inside a live candle. Turn off only for faster but unstable intrabar signals.")
fixTrend = input.bool(true, "Trend filter (EMA)", group = gF, tooltip = "FIX counter-trend signals: Buy needs close above a rising EMA, Sell needs close below a falling EMA. Off allows signals against the larger trend.")
trendLen = input.int(200, "Trend EMA length", minval = 20, maxval = 500, group = gF, tooltip = "EMA period for the trend filter. Longer follows the major trend and filters more; shorter follows the swing trend and lets more signals through.")
fixAdx = input.bool(true, "Sideways filter (ADX)", group = gF, tooltip = "FIX sideways false signals: entries require ADX at or above the minimum, so flat, directionless markets are skipped.")
adxLen = input.int(14, "ADX length", minval = 5, maxval = 50, group = gF, tooltip = "Period of the DMI/ADX calculation. Longer is smoother but slower to show a new trend; shorter reacts faster but is noisier.")
adxMin = input.float(18.0, "Min. ADX", minval = 5.0, maxval = 50.0, step = 0.5, group = gF, tooltip = "Minimum ADX for an entry. Higher accepts only strong trends and fewer signals; lower allows entries in weaker trends.")
fixVol = input.bool(true, "Volume confirmation", group = gF, tooltip = "FIX weak breakouts: the breakout bar volume must exceed its average times the multiple. Ignored automatically on symbols without volume data.")
volLen = input.int(20, "Volume average length", minval = 5, maxval = 200, group = gF, tooltip = "Bars used for the average volume. Longer gives a stable baseline; shorter compares against recent activity only.")
volMult = input.float(1.2, "Volume multiple", minval = 0.5, maxval = 5.0, step = 0.1, group = gF, tooltip = "Breakout volume must be at least this multiple of the average. Higher demands stronger participation and gives fewer signals.")
fixBody = input.bool(true, "Strong breakout candle", group = gF, tooltip = "FIX wick breakouts: the breakout candle must close in the signal direction with a solid body relative to its range.")
bodyMin = input.float(0.5, "Min. body / range", minval = 0.1, maxval = 1.0, step = 0.05, group = gF, tooltip = "Minimum body size as a fraction of the candle range. Higher requires more decisive candles; lower accepts candles with long wicks.")
fixChase = input.bool(true, "Max chase distance", group = gF, tooltip = "FIX late entries from filter lag: no entry if price has already run too far beyond the end of wave 1.")
chaseMax = input.float(2.0, "Max chase (x ATR)", minval = 0.5, maxval = 10.0, step = 0.1, group = gF, tooltip = "Largest allowed distance from the wave 1 level to the close at entry. Lower avoids buying extended moves; higher allows later entries.")
fixCool = input.bool(true, "Cooldown between main signals", group = gF, tooltip = "FIX clustered signals: after a main Buy or Sell, new main signals are blocked for a number of bars.")
coolBars = input.int(10, "Cooldown (bars)", minval = 1, maxval = 200, group = gF, tooltip = "Bars to wait after a main signal before another main signal may fire. Higher reduces flip-flopping; lower allows quicker reversals.")
gP = "Pyramid"
pyrOn = input.bool(true, "Enable pyramid", group = gP, tooltip = "Adds extra orders in the direction of the open signal when price moves the set distance from the last order. Off shows main signals only.")
pyrMax = input.int(4, "Max orders per side", minval = 1, maxval = 10, group = gP, tooltip = "Total orders allowed per side, including the first one. Higher allows more adds and larger exposure; 1 disables adds.")
pyrMode = input.string("ATR", "Spacing mode", options = ["Ticks", "ATR"], group = gP, tooltip = "How the distance between orders is measured: a fixed number of ticks, or a multiple of ATR that adapts to volatility.")
pyrTicks = input.int(200, "Spacing (ticks)", minval = 1, maxval = 100000, group = gP, tooltip = "Distance between orders in minimum ticks when spacing mode is Ticks. Higher spaces adds further apart; lower adds more often.")
pyrAtrLen = input.int(14, "Spacing ATR length", minval = 5, maxval = 200, group = gP, tooltip = "ATR period used for spacing when spacing mode is ATR. Longer gives steadier spacing; shorter follows recent volatility.")
pyrAtrMult = input.float(1.0, "Spacing ATR multiplier", minval = 0.1, maxval = 10.0, step = 0.1, group = gP, tooltip = "Distance between orders in ATRs when spacing mode is ATR. Higher spaces adds further apart; lower adds more often.")
pyrDir = input.string("With trend", "Add direction", options = ["With trend", "On pullback"], group = gP, tooltip = "With trend: Buy adds when price rises the set distance above the last buy (Sell: falls below). On pullback: Buy adds when price drops the distance below the last buy (Sell: rises above).")
pyrStopInv = input.bool(true, "Stop adding after invalidation", group = gP, tooltip = "If price closes beyond the start of wave 1 (rule 1 broken), no further adds are made for that side until a new main signal.")
gD = "Display"
showWaves = input.bool(true, "Show wave 0-1-2 labels", group = gD, tooltip = "Marks the start of wave 1, the end of wave 1 and the end of wave 2 of each armed setup, with the measured wave 2 retracement.")
showTgt = input.bool(true, "Show wave 3 targets", group = gD, tooltip = "After a main signal, draws wave 3 Fibonacci targets (1.618 and 2.618 of wave 1 from the end of wave 2) and the invalidation level.")
showOrdLbl = input.bool(true, "Show order numbers", group = gD, tooltip = "Shows B1, B2... and S1, S2... labels so first orders and pyramid adds can be told apart.")
showEma = input.bool(false, "Show trend EMA", group = gD, tooltip = "Plots the trend filter EMA on the chart.")
showPanel = input.bool(true, "Show status panel", group = gD, tooltip = "Shows a small table with armed setups, open side, order count and filter status.")
panelPos = input.string("Top Right", "Panel position", options = ["Top Right", "Bottom Right", "Top Left", "Bottom Left"], group = gD, tooltip = "Corner of the chart where the status panel is drawn.")
// ─────────────────────────────────────────────────────────────────────────
// COLOURS
// ─────────────────────────────────────────────────────────────────────────
BULL = #22C55E
BULL_ADD = #86EFAC
BEAR = #EF4444
BEAR_ADD = #FCA5A5
NEUTRAL = #8A8F9C
INK = #0E0A18
px(float v) =>
str.tostring(v, format.mintick)
// ─────────────────────────────────────────────────────────────────────────
// SERIES (every bar)
// ─────────────────────────────────────────────────────────────────────────
atr = ta.atr(atrLen)
pAtr = ta.atr(pyrAtrLen)
ph = ta.pivothigh(high, pivLen, pivLen)
pl = ta.pivotlow(low, pivLen, pivLen)
pBar = bar_index - pivLen
ema = ta.ema(close, trendLen)
emaPrv = ema[1]
[diP, diM, adx] = ta.dmi(adxLen, adxLen)
volAvg = ta.sma(nz(volume), volLen)
rng = high - low
bodyR = rng > 0 ? math.abs(close - open) / rng : 0.0
// FIX: trend filter
trendL = not fixTrend or (close > ema and ema >= emaPrv)
trendS = not fixTrend or (close < ema and ema <= emaPrv)
// FIX: sideways (ADX) filter
adxOk = not fixAdx or (not na(adx) and adx >= adxMin)
// FIX: volume confirmation (passes when the symbol has no volume)
volOk = not fixVol or volAvg <= 0 or nz(volume) >= volAvg * volMult
// FIX: strong breakout candle
bodyL = not fixBody or (close > open and bodyR >= bodyMin)
bodyS = not fixBody or (close < open and bodyR >= bodyMin)
longAllowed = side != "Short only"
shortAllowed = side != "Long only"
// FIX: repaint - run the logic only on closed bars
canRun = (not fixConfirm or barstate.isconfirmed) and not na(atr)
// ─────────────────────────────────────────────────────────────────────────
// STATE
// ─────────────────────────────────────────────────────────────────────────
var array<float> swP = array.new_float() // confirmed swing prices (alternating high/low)
var array<int> swB = array.new_int()
var array<bool> swH = array.new_bool()
// armed wave 1-2 setups
var bool bullArmed = false
var bool bullUsed = false
var float bullLvl = na // end of wave 1 (breakout level)
var float bullInv = na // start of wave 1 (rule 1)
var float bullW2 = na
var float bullW1 = na
var int bullBar = na
var label bl0 = na
var label bl1 = na
var label bl2 = na
var bool bearArmed = false
var bool bearUsed = false
var float bearLvl = na
var float bearInv = na
var float bearW2 = na
var float bearW1 = na
var int bearBar = na
var label sl0 = na
var label sl1 = na
var label sl2 = na
// open side and pyramid
var int buyCount = 0
var float lastBuyPrice = na
var bool longLive = false
var float longInv = na
var int sellCount = 0
var float lastSellPrice = na
var bool shortLive = false
var float shortInv = na
var int lastMainBar = na
// wave 3 target drawings
var line tg1L = na
var line tg2L = na
var line invL = na
var label tg1B = na
var label tg2B = na
var label invB = na
buySig = false
sellSig = false
pyrBuy = false
pyrSell = false
invLong = false
invShort = false
zChanged = false
// adds a confirmed swing to the zigzag; returns true if the structure changed
addSwing(float p, int b, bool isHigh) =>
bool changed = false
n = array.size(swP)
if n == 0
array.push(swP, p)
array.push(swB, b)
array.push(swH, isHigh)
changed := true
else if array.last(swH) == isHigh
// same kind of swing: keep only the more extreme one
if (isHigh and p > array.last(swP)) or (not isHigh and p < array.last(swP))
array.set(swP, n - 1, p)
array.set(swB, n - 1, b)
changed := true
else
mv = isHigh ? p - array.last(swP) : array.last(swP) - p
if mv >= swingMin * atr and b > array.last(swB)
array.push(swP, p)
array.push(swB, b)
array.push(swH, isHigh)
if array.size(swP) > 10
array.shift(swP)
array.shift(swB)
array.shift(swH)
changed := true
changed
// ─────────────────────────────────────────────────────────────────────────
// LOGIC (closed bars)
// ─────────────────────────────────────────────────────────────────────────
if canRun
// ── 1. swings
lastHigh = array.size(swH) > 0 and array.last(swH)
if lastHigh
if not na(pl)
zChanged := addSwing(pl, pBar, false) or zChanged
if not na(ph)
zChanged := addSwing(ph, pBar, true) or zChanged
else
if not na(ph)
zChanged := addSwing(ph, pBar, true) or zChanged
if not na(pl)
zChanged := addSwing(pl, pBar, false) or zChanged
// ── 2. evaluate wave 1-2 on the last three swings
if zChanged and array.size(swP) >= 3
n = array.size(swP)
p0 = array.get(swP, n - 3)
p1 = array.get(swP, n - 2)
p2 = array.get(swP, n - 1)
b0 = array.get(swB, n - 3)
b1 = array.get(swB, n - 2)
b2 = array.get(swB, n - 1)
len1 = math.abs(p1 - p0)
retr = len1 > 0 ? math.abs(p2 - p1) / len1 : na
okShape = not na(retr) and len1 >= w1Min * atr and retr >= r2Min and retr <= r2Max
if not array.last(swH)
// bullish: low (0) -> high (1) -> higher low (2)
if not bullUsed
label.delete(bl0)
label.delete(bl1)
label.delete(bl2)
bl0 := na
bl1 := na
bl2 := na
bullUsed := false
bullArmed := okShape and p2 > p0
if bullArmed
bullLvl := p1
bullInv := p0
bullW2 := p2
bullW1 := len1
bullBar := bar_index
if showWaves
bl0 := label.new(b0, p0, "0", style = label.style_label_up, color = color.new(NEUTRAL, 10), textcolor = color.white, size = size.small)
bl1 := label.new(b1, p1, "1", style = label.style_label_down, color = BULL, textcolor = INK, size = size.small)
bl2 := label.new(b2, p2, "2 · " + str.tostring(retr, "0.000"), style = label.style_label_up, color = BULL, textcolor = INK, size = size.small)
else
// bearish: high (0) -> low (1) -> lower high (2)
if not bearUsed
label.delete(sl0)
label.delete(sl1)
label.delete(sl2)
sl0 := na
sl1 := na
sl2 := na
bearUsed := false
bearArmed := okShape and p2 < p0
if bearArmed
bearLvl := p1
bearInv := p0
bearW2 := p2
bearW1 := len1
bearBar := bar_index
if showWaves
sl0 := label.new(b0, p0, "0", style = label.style_label_down, color = color.new(NEUTRAL, 10), textcolor = color.white, size = size.small)
sl1 := label.new(b1, p1, "1", style = label.style_label_up, color = BEAR, textcolor = color.white, size = size.small)
sl2 := label.new(b2, p2, "2 · " + str.tostring(retr, "0.000"), style = label.style_label_down, color = BEAR, textcolor = color.white, size = size.small)
// ── 3. cancel setups: rule 1 broken or expired
if bullArmed and (close < bullInv or bar_index - bullBar > setupLife)
bullArmed := false
label.delete(bl0)
label.delete(bl1)
label.delete(bl2)
bl0 := na
bl1 := na
bl2 := na
if bearArmed and (close > bearInv or bar_index - bearBar > setupLife)
bearArmed := false
label.delete(sl0)
label.delete(sl1)
label.delete(sl2)
sl0 := na
sl1 := na
sl2 := na
// ── 4. main signals: close beyond the end of wave 1 = wave 3 launch
// FIX: cooldown between main signals
coolOk = not fixCool or na(lastMainBar) or bar_index - lastMainBar >= coolBars
if bullArmed and longAllowed and coolOk
brkL = close > bullLvl + brkBuf * atr
chaseL = not fixChase or close - bullLvl <= chaseMax * atr // FIX: max chase
buySig := brkL and chaseL and trendL and adxOk and volOk and bodyL
if bearArmed and shortAllowed and coolOk
brkS = close < bearLvl - brkBuf * atr
chaseS = not fixChase or bearLvl - close <= chaseMax * atr
sellSig := brkS and chaseS and trendS and adxOk and volOk and bodyS
if buySig and sellSig
buySig := false
sellSig := false
if buySig
bullArmed := false
bullUsed := true
lastMainBar := bar_index
buyCount := 1
lastBuyPrice := close
longLive := true
longInv := bullInv
sellCount := 0 // opposite side resets
lastSellPrice := na
shortLive := false
line.delete(tg1L)
line.delete(tg2L)
line.delete(invL)
label.delete(tg1B)
label.delete(tg2B)
label.delete(invB)
tg1L := na
tg2L := na
invL := na
tg1B := na
tg2B := na
invB := na
if showTgt
t1 = bullW2 + 1.618 * bullW1
t2 = bullW2 + 2.618 * bullW1
tg1L := line.new(bar_index, t1, bar_index + 5, t1, color = BULL, width = 2)
tg2L := line.new(bar_index, t2, bar_index + 5, t2, color = BULL, width = 1, style = line.style_dashed)
invL := line.new(bar_index, longInv, bar_index + 5, longInv, color = NEUTRAL, style = line.style_dotted)
tg1B := label.new(bar_index + 5, t1, "W3 1.618 " + px(t1), style = label.style_label_left, color = INK, textcolor = BULL, size = size.small)
tg2B := label.new(bar_index + 5, t2, "W3 2.618 " + px(t2), style = label.style_label_left, color = INK, textcolor = BULL, size = size.small)
invB := label.new(bar_index + 5, longInv, "Invalid " + px(longInv), style = label.style_label_left, color = INK, textcolor = NEUTRAL, size = size.small)
if sellSig
bearArmed := false
bearUsed := true
lastMainBar := bar_index
sellCount := 1
lastSellPrice := close
shortLive := true
shortInv := bearInv
buyCount := 0
lastBuyPrice := na
longLive := false
line.delete(tg1L)
line.delete(tg2L)
line.delete(invL)
label.delete(tg1B)
label.delete(tg2B)
label.delete(invB)
tg1L := na
tg2L := na
invL := na
tg1B := na
tg2B := na
invB := na
if showTgt
t1 = bearW2 - 1.618 * bearW1
t2 = bearW2 - 2.618 * bearW1
tg1L := line.new(bar_index, t1, bar_index + 5, t1, color = BEAR, width = 2)
tg2L := line.new(bar_index, t2, bar_index + 5, t2, color = BEAR, width = 1, style = line.style_dashed)
invL := line.new(bar_index, shortInv, bar_index + 5, shortInv, color = NEUTRAL, style = line.style_dotted)
tg1B := label.new(bar_index + 5, t1, "W3 1.618 " + px(t1), style = label.style_label_left, color = INK, textcolor = BEAR, size = size.small)
tg2B := label.new(bar_index + 5, t2, "W3 2.618 " + px(t2), style = label.style_label_left, color = INK, textcolor = BEAR, size = size.small)
invB := label.new(bar_index + 5, shortInv, "Invalid " + px(shortInv), style = label.style_label_left, color = INK, textcolor = NEUTRAL, size = size.small)
// ── 5. invalidation of the open side (rule 1: close beyond start of wave 1)
if longLive and not buySig and close < longInv
invLong := true
if pyrStopInv
longLive := false
if shortLive and not sellSig and close > shortInv
invShort := true
if pyrStopInv
shortLive := false
// ── 6. pyramid adds
// With trend : Buy adds when close >= last buy + distance; Sell adds when close <= last sell - distance
// On pullback: Buy adds when close <= last buy - distance; Sell adds when close >= last sell + distance
// Adds always require the wave 1 start (rule 1) to hold.
dist = pyrMode == "Ticks" ? pyrTicks * syminfo.mintick : pyrAtrMult * pAtr
if pyrOn and longLive and not buySig and buyCount >= 1 and buyCount < pyrMax and not na(dist)
condL = pyrDir == "With trend" ? close >= lastBuyPrice + dist : close <= lastBuyPrice - dist
if condL and close > longInv
pyrBuy := true
buyCount += 1
lastBuyPrice := close
if pyrOn and shortLive and not sellSig and sellCount >= 1 and sellCount < pyrMax and not na(dist)
condS = pyrDir == "With trend" ? close <= lastSellPrice - dist : close >= lastSellPrice + dist
if condS and close < shortInv
pyrSell := true
sellCount += 1
lastSellPrice := close
// target lines follow the current bar
if not na(tg1L)
line.set_x2(tg1L, bar_index + 5)
label.set_x(tg1B, bar_index + 5)
if not na(tg2L)
line.set_x2(tg2L, bar_index + 5)
label.set_x(tg2B, bar_index + 5)
if not na(invL)
line.set_x2(invL, bar_index + 5)
label.set_x(invB, bar_index + 5)
// ─────────────────────────────────────────────────────────────────────────
// PLOTS
// ─────────────────────────────────────────────────────────────────────────
plot(showEma ? ema : na, "Trend EMA", color = color.new(color.orange, 20), linewidth = 2)
plotshape(buySig, title = "Buy", style = shape.triangleup, location = location.belowbar, color = BULL, size = size.small)
plotshape(pyrBuy, title = "Pyramid Buy", style = shape.circle, location = location.belowbar, color = BULL_ADD, size = size.tiny)
plotshape(sellSig, title = "Sell", style = shape.triangledown, location = location.abovebar, color = BEAR, size = size.small)
plotshape(pyrSell, title = "Pyramid Sell", style = shape.circle, location = location.abovebar, color = BEAR_ADD, size = size.tiny)
plotshape(invLong, title = "Long invalidated", style = shape.xcross, location = location.belowbar, color = NEUTRAL, size = size.tiny)
plotshape(invShort, title = "Short invalidated", style = shape.xcross, location = location.abovebar, color = NEUTRAL, size = size.tiny)
if showOrdLbl and (buySig or pyrBuy)
label.new(bar_index, low - 0.8 * atr, "B" + str.tostring(buyCount), style = label.style_label_up, color = buySig ? BULL : BULL_ADD, textcolor = INK, size = buySig ? size.normal : size.small)
if showOrdLbl and (sellSig or pyrSell)
label.new(bar_index, high + 0.8 * atr, "S" + str.tostring(sellCount), style = label.style_label_down, color = sellSig ? BEAR : BEAR_ADD, textcolor = sellSig ? color.white : INK, size = sellSig ? size.normal : size.small)
// ─────────────────────────────────────────────────────────────────────────
// PANEL
// ─────────────────────────────────────────────────────────────────────────
pos = panelPos == "Top Right" ? position.top_right : panelPos == "Bottom Right" ? position.bottom_right : panelPos == "Top Left" ? position.top_left : position.bottom_left
var table tb = table.new(pos, 2, 6, bgcolor = color.new(INK, 10), border_color = color.new(NEUTRAL, 60), border_width = 1, frame_color = color.new(NEUTRAL, 40), frame_width = 1)
if barstate.islast and showPanel
table.cell(tb, 0, 0, "EW3 Launch", text_color = color.white, text_size = size.small)
table.cell(tb, 1, 0, longLive ? "LONG" : shortLive ? "SHORT" : "FLAT", text_color = longLive ? BULL : shortLive ? BEAR : NEUTRAL, text_size = size.small)
table.cell(tb, 0, 1, "Bull setup", text_color = NEUTRAL, text_size = size.small)
table.cell(tb, 1, 1, bullArmed ? "> " + px(bullLvl) : "—", text_color = bullArmed ? BULL : NEUTRAL, text_size = size.small)
table.cell(tb, 0, 2, "Bear setup", text_color = NEUTRAL, text_size = size.small)
table.cell(tb, 1, 2, bearArmed ? "< " + px(bearLvl) : "—", text_color = bearArmed ? BEAR : NEUTRAL, text_size = size.small)
table.cell(tb, 0, 3, "Orders", text_color = NEUTRAL, text_size = size.small)
table.cell(tb, 1, 3, longLive ? str.tostring(buyCount) + "/" + str.tostring(pyrMax) : shortLive ? str.tostring(sellCount) + "/" + str.tostring(pyrMax) : "0/" + str.tostring(pyrMax), text_color = color.white, text_size = size.small)
table.cell(tb, 0, 4, "Trend", text_color = NEUTRAL, text_size = size.small)
table.cell(tb, 1, 4, not fixTrend ? "off" : close > ema ? "up" : "down", text_color = not fixTrend ? NEUTRAL : close > ema ? BULL : BEAR, text_size = size.small)
table.cell(tb, 0, 5, "ADX", text_color = NEUTRAL, text_size = size.small)
table.cell(tb, 1, 5, na(adx) ? "—" : str.tostring(adx, "0.0"), text_color = adxOk ? BULL : NEUTRAL, text_size = size.small)
// ─────────────────────────────────────────────────────────────────────────
// ALERTS
// ─────────────────────────────────────────────────────────────────────────
alertcondition(buySig, "Buy", "{{ticker}} EW3 Launch: BUY - bullish wave 3 breakout")
alertcondition(sellSig, "Sell", "{{ticker}} EW3 Launch: SELL - bearish wave 3 breakout")
alertcondition(pyrBuy, "Pyramid Buy", "{{ticker}} EW3 Launch: pyramid BUY add")
alertcondition(pyrSell, "Pyramid Sell", "{{ticker}} EW3 Launch: pyramid SELL add")
alertcondition(invLong or invShort, "Invalidation", "{{ticker}} EW3 Launch: rule 1 broken, wave count invalidated")