本页源码来自 TradingView 公开发布的开源脚本,版权归原作者所有, 请遵循其原始许可(Pine 脚本常见 CC BY-NC-SA / MPL-2.0 / MIT)。 本项目仅用于研究检索与许可范围内的移植。
//@version=6
// This Pine Script™ code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © EyeAlgo
indicator("Eye Divergence Engine [EyeAlgo]", shorttitle = "Eye Divergence Engine", overlay = false, max_lines_count = 500, max_labels_count = 500)
// ═════════════════════════ INPUTS ═════════════════════════
grpP = "Pivots"
pvL = input.int(5, "Pivot left bars", minval = 2, maxval = 30, group = grpP)
pvR = input.int(3, "Pivot right bars (confirm delay)", minval = 1, maxval = 15, group = grpP, tooltip = "A divergence is confirmed this many bars after the pivot. Higher = fewer, cleaner pivots but later.")
minGap = input.int(5, "Min bars between pivots", minval = 2, maxval = 50, group = grpP)
maxGap = input.int(80, "Max bars between pivots", minval = 10, maxval = 300, group = grpP)
grpO = "Oscillators (each one is a vote)"
useRsi = input.bool(true, "RSI", inline = "o1", group = grpO)
rsiLen = input.int(14, "", minval = 2, inline = "o1", group = grpO)
useMacd = input.bool(true, "MACD histogram", inline = "o2", group = grpO)
macdF = input.int(12, "", minval = 1, inline = "o2", group = grpO)
macdS = input.int(26, "", minval = 2, inline = "o2", group = grpO)
macdG = input.int(9, "", minval = 1, inline = "o2", group = grpO)
useSto = input.bool(true, "Stochastic %K", inline = "o3", group = grpO)
stoLen = input.int(14, "", minval = 2, inline = "o3", group = grpO)
stoSm = input.int(3, "", minval = 1, inline = "o3", group = grpO)
useCci = input.bool(true, "CCI", inline = "o4", group = grpO)
cciLen = input.int(20, "", minval = 2, inline = "o4", group = grpO)
useMfi = input.bool(true, "MFI (needs volume)", inline = "o5", group = grpO)
mfiLen = input.int(14, "", minval = 2, inline = "o5", group = grpO)
useObv = input.bool(true, "OBV (needs volume)", group = grpO)
useMom = input.bool(true, "Momentum", inline = "o7", group = grpO)
momLen = input.int(10, "", minval = 1, inline = "o7", group = grpO)
grpS = "Signal filters"
minVotes = input.int(4, "Min oscillators agreeing", minval = 1, maxval = 7, group = grpS)
minOscDiv = input.float(8.0, "Min oscillator divergence (points)", minval = 0, step = 1, group = grpS, tooltip = "Average gap between the two oscillator pivots of the voting oscillators, on the −100..+100 scale. Higher = only clear divergences.")
minPxDiv = input.float(0.1, "Min price difference (× ATR)", minval = 0, step = 0.05, group = grpS, tooltip = "Gap between the two price pivots, in ATR. Removes near-equal pivots.")
showReg = input.bool(true, "Regular divergence (reversal)", group = grpS)
zoneLvl = input.int(25, "Regular: Eye Composite zone level", minval = 0, maxval = 90, group = grpS, tooltip = "Regular bull needs the Eye Composite at or below −level at the pivot; regular bear at or above +level.")
showHid = input.bool(true, "Hidden divergence (continuation)", group = grpS)
emaLen = input.int(200, "Hidden: trend EMA length", minval = 10, group = grpS, tooltip = "Hidden bull needs close above a rising EMA; hidden bear needs close below a falling EMA.")
minGrade = input.string("C", "Min grade to show", options = ["A", "B", "C"], group = grpS)
grpE = "Entry trigger"
trigWin = input.int(6, "Trigger window (bars)", minval = 1, maxval = 50, group = grpE, tooltip = "After a divergence is confirmed, a bar must CLOSE beyond the high (bull) / low (bear) of the pivot-to-confirm bars within this many bars. If price breaks the pivot first or time runs out, the setup is cancelled.")
atrLen = input.int(14, "ATR length", minval = 1, group = grpE)
grpV = "Visuals"
showPriceDraw = input.bool(true, "Divergence lines + labels on price chart", group = grpV)
showPaneLines = input.bool(true, "Divergence lines in oscillator pane", group = grpV)
maxKeep = input.int(60, "Divergences kept on chart", minval = 5, maxval = 120, group = grpV)
showDash = input.bool(true, "Show dashboard", group = grpV)
dashOnPrice = input.bool(true, "Dashboard on price chart", group = grpV)
dashPosIn = input.string("Top Right", "Dashboard position", options = ["Top Right", "Top Left", "Bottom Right", "Bottom Left"], group = grpV)
styleIn = input.string("Modern", "Style", options = ["Modern", "Classic"], group = grpV, tooltip = "Modern: gradient line and area, soft zone bands and turning dots. Classic: plain line and histogram.")
colBull = input.color(#00E5A8, "Bullish", inline = "c", group = grpV)
colBear = input.color(#FF3D71, "Bearish", inline = "c", group = grpV)
colorCandles = input.bool(true, "Colour candles by Eye Composite", group = grpV)
neo = styleIn == "Modern"
cBg = #0B1220
cPanel = #0F172A
cEdge = #1E293B
cText = #E2E8F0
cMuted = #94A3B8
// ═════════════════════════ TYPES ═════════════════════════
type Div
int dir
int typ
float trig
float pivPx
int pivBar
int prevBar
float prevPx
float prevComp
float pivComp
int expiry
int votes
int mask
int score
string grade
// ═════════════════════════ OSCILLATORS ═════════════════════════
atr = ta.atr(atrLen)
hasVol = ta.cum(nz(volume)) > 0
rsiV = ta.rsi(close, rsiLen)
macdL = ta.ema(close, macdF) - ta.ema(close, macdS)
macdH = macdL - ta.ema(macdL, macdG)
stoK = ta.sma(ta.stoch(close, high, low, stoLen), stoSm)
cciV = ta.cci(hlc3, cciLen)
mfiV = ta.mfi(hlc3, mfiLen)
obvV = ta.obv
momV = ta.mom(close, momLen)
enRsi = useRsi
enMacd = useMacd
enSto = useSto
enCci = useCci
enMfi = useMfi and hasVol
enObv = useObv and hasVol
enMom = useMom
// Eye Composite: every enabled oscillator scaled to −100..+100, then averaged
clamp(float x) => math.max(-100.0, math.min(100.0, x))
macdSd = ta.stdev(macdH, 100)
obvDev = obvV - ta.ema(obvV, 20)
obvSd = ta.stdev(obvDev, 100)
momSc = atr * math.sqrt(momLen)
nRsi = clamp((rsiV - 50) * 2)
nMacd = macdSd > 0 ? clamp(macdH / macdSd * 40) : 0.0
nSto = clamp((stoK - 50) * 2)
nCci = clamp(cciV / 2)
nMfi = clamp((mfiV - 50) * 2)
nObv = obvSd > 0 ? clamp(obvDev / obvSd * 40) : 0.0
nMom = momSc > 0 ? clamp(momV / momSc * 50) : 0.0
compSum = (enRsi ? nz(nRsi) : 0.0) + (enMacd ? nz(nMacd) : 0.0) + (enSto ? nz(nSto) : 0.0) + (enCci ? nz(nCci) : 0.0) + (enMfi ? nz(nMfi) : 0.0) + (enObv ? nz(nObv) : 0.0) + (enMom ? nz(nMom) : 0.0)
enN = (enRsi ? 1 : 0) + (enMacd ? 1 : 0) + (enSto ? 1 : 0) + (enCci ? 1 : 0) + (enMfi ? 1 : 0) + (enObv ? 1 : 0) + (enMom ? 1 : 0)
comp = ta.ema(enN > 0 ? compSum / enN : 0.0, 3)
trendE = ta.ema(close, emaLen)
needVotes = math.min(minVotes, enN)
emaUp = trendE > trendE[5]
emaDn = trendE < trendE[5]
// ═════════════════════════ HELPERS ═════════════════════════
oscNames = array.from("RSI", "MACD", "Stochastic", "CCI", "MFI", "OBV", "Momentum")
typNames = array.from("Regular Bull", "Regular Bear", "Hidden Bull", "Hidden Bear")
// votes, voter mask, average normalized divergence of the voters
f_eval(array<float> prevO, array<float> curO, array<float> prevN, array<float> curN, array<bool> en, bool oscUp) =>
int v = 0
int m = 0
float s = 0.0
for i = 0 to 6
if array.get(en, i)
float a = array.get(prevO, i)
float b = array.get(curO, i)
if not na(a) and not na(b)
if oscUp ? b > a : b < a
float pn = nz(array.get(prevN, i))
float cn = nz(array.get(curN, i))
v += 1
m += int(math.pow(2, i))
s += oscUp ? cn - pn : pn - cn
[v, m, v > 0 ? s / v : 0.0]
// 0–100 quality score
f_score(int v, int n, float oscDiv, float pxDiv, float zoneDepth) =>
float s = 40.0 * v / math.max(n, 1) + 30.0 * math.min(math.max(oscDiv, 0) / 30.0, 1.0) + 10.0 * math.min(pxDiv, 1.0) + 20.0 * zoneDepth
int(math.round(s))
f_rank(string g) => g == "A" ? 0 : g == "B" ? 1 : 2
f_hasBit(int msk, int j) => math.floor(msk / int(math.pow(2, j))) % 2 == 1
isConf = barstate.isconfirmed
minRank = f_rank(minGrade)
// ═════════════════════════ PENDING SETUPS → TRIGGER ═════════════════════════
var array<Div> pend = array.new<Div>()
int sigType = -1
Div sig = na
if isConf and array.size(pend) > 0
for i = array.size(pend) - 1 to 0
Div d = array.get(pend, i)
bool fire = d.dir == 1 ? close > d.trig : close < d.trig
bool dead = d.dir == 1 ? low < d.pivPx : high > d.pivPx
if fire or dead or bar_index >= d.expiry
if fire and not dead and sigType == -1
sigType := d.typ
sig := d
array.remove(pend, i)
sigBull = sigType == 0 or sigType == 2
sigBear = sigType == 1 or sigType == 3
// ═════════════════════════ DIVERGENCE DETECTION ═════════════════════════
pl = ta.pivotlow(low, pvL, pvR)
ph = ta.pivothigh(high, pvL, pvR)
valsNow = array.from(rsiV[pvR], macdH[pvR], stoK[pvR], cciV[pvR], mfiV[pvR], obvV[pvR], momV[pvR])
normNow = array.from(nRsi[pvR], nMacd[pvR], nSto[pvR], nCci[pvR], nMfi[pvR], nObv[pvR], nMom[pvR])
enArr = array.from(enRsi, enMacd, enSto, enCci, enMfi, enObv, enMom)
compPiv = comp[pvR]
trigHi = ta.highest(high, pvR + 1)
trigLo = ta.lowest(low, pvR + 1)
atrPiv = atr[pvR]
var int lPrevBar = na
var float lPrevPx = na
var float lPrevComp = na
var array<float> lPrevOsc = array.new_float(7, na)
var array<float> lPrevN = array.new_float(7, na)
var int hPrevBar = na
var float hPrevPx = na
var float hPrevComp = na
var array<float> hPrevOsc = array.new_float(7, na)
var array<float> hPrevN = array.new_float(7, na)
// pivot low → bullish setups
if isConf and not na(pl)
int cb = bar_index - pvR
if not na(lPrevBar) and cb - lPrevBar >= minGap and cb - lPrevBar <= maxGap and pl != lPrevPx and enN > 0
bool isReg = pl < lPrevPx
[v, m, od] = f_eval(lPrevOsc, valsNow, lPrevN, normNow, enArr, isReg)
float pxd = atrPiv > 0 ? math.abs(pl - lPrevPx) / atrPiv : 0.0
bool typeOk = isReg ? showReg and compPiv <= -zoneLvl : showHid and close > trendE and emaUp and compPiv <= 0
if typeOk and v >= needVotes and od >= minOscDiv and pxd >= minPxDiv
float zd = isReg ? math.min(math.abs(compPiv) / 60.0, 1.0) : math.min(math.max(-compPiv, 0) / 40.0, 1.0)
int sc = f_score(v, enN, od, pxd, zd)
string g = sc >= 75 ? "A" : sc >= 55 ? "B" : "C"
if f_rank(g) <= minRank
array.push(pend, Div.new(1, isReg ? 0 : 2, trigHi, pl, cb, lPrevBar, lPrevPx, lPrevComp, compPiv, bar_index + trigWin, v, m, sc, g))
lPrevBar := cb
lPrevPx := pl
lPrevComp := compPiv
lPrevOsc := array.copy(valsNow)
lPrevN := array.copy(normNow)
// pivot high → bearish setups
if isConf and not na(ph)
int cb = bar_index - pvR
if not na(hPrevBar) and cb - hPrevBar >= minGap and cb - hPrevBar <= maxGap and ph != hPrevPx and enN > 0
bool isReg = ph > hPrevPx
[v, m, od] = f_eval(hPrevOsc, valsNow, hPrevN, normNow, enArr, not isReg)
float pxd = atrPiv > 0 ? math.abs(ph - hPrevPx) / atrPiv : 0.0
bool typeOk = isReg ? showReg and compPiv >= zoneLvl : showHid and close < trendE and emaDn and compPiv >= 0
if typeOk and v >= needVotes and od >= minOscDiv and pxd >= minPxDiv
float zd = isReg ? math.min(math.abs(compPiv) / 60.0, 1.0) : math.min(math.max(compPiv, 0) / 40.0, 1.0)
int sc = f_score(v, enN, od, pxd, zd)
string g = sc >= 75 ? "A" : sc >= 55 ? "B" : "C"
if f_rank(g) <= minRank
array.push(pend, Div.new(-1, isReg ? 1 : 3, trigLo, ph, cb, hPrevBar, hPrevPx, hPrevComp, compPiv, bar_index + trigWin, v, m, sc, g))
hPrevBar := cb
hPrevPx := ph
hPrevComp := compPiv
hPrevOsc := array.copy(valsNow)
hPrevN := array.copy(normNow)
while array.size(pend) > 20
array.shift(pend)
// ═════════════════════════ LAST SIGNAL ═════════════════════════
var int lastType = -1
var int lastVotes = 0
var int lastEnN = 0
var int lastScore = 0
var string lastGrade = ""
var int lastBar = na
var float lastInv = na
var int lastMask = 0
if sigType >= 0
lastType := sigType
lastVotes := sig.votes
lastEnN := enN
lastScore := sig.score
lastGrade := sig.grade
lastBar := bar_index
lastInv := sig.pivPx
lastMask := sig.mask
// ═════════════════════════ DRAWINGS (only for triggered setups) ═════════════════════════
var array<line> dLines = array.new_line()
var array<label> dLabels = array.new_label()
var array<int> dGroups = array.new_int()
if sigType >= 0
color c = sigBull ? colBull : colBear
int x1 = math.max(sig.prevBar, bar_index - 4900)
string lst = sigType >= 2 ? line.style_dashed : line.style_solid
int nL = 0
label lb = na
if showPriceDraw
if neo
array.push(dLines, line.new(x1, sig.prevPx, sig.pivBar, sig.pivPx, color = color.new(c, 78), width = 7, force_overlay = true))
nL += 1
array.push(dLines, line.new(x1, sig.prevPx, sig.pivBar, sig.pivPx, color = c, width = 2, style = lst, force_overlay = true))
nL += 1
string txt = array.get(typNames, sigType) + " · " + str.tostring(sig.votes) + "/" + str.tostring(enN) + " · " + sig.grade + " " + str.tostring(sig.score)
lb := label.new(sig.pivBar, sig.pivPx, txt, style = sigBull ? label.style_label_up : label.style_label_down, color = neo ? color.new(c, 5) : color.new(c, 10), textcolor = neo ? cBg : color.white, size = size.small, force_overlay = true)
if showPaneLines and not na(sig.prevComp) and not na(sig.pivComp)
if neo
array.push(dLines, line.new(x1, sig.prevComp, sig.pivBar, sig.pivComp, color = color.new(c, 78), width = 7))
nL += 1
array.push(dLines, line.new(x1, sig.prevComp, sig.pivBar, sig.pivComp, color = c, width = 2, style = lst))
nL += 1
array.push(dLabels, lb)
array.push(dGroups, nL)
while array.size(dGroups) > maxKeep
int k = array.shift(dGroups)
if k > 0
for _i = 1 to k
line.delete(array.shift(dLines))
label.delete(array.shift(dLabels))
// ═════════════════════════ PLOTS ═════════════════════════
cMid = #64748B
compCol = comp >= 0 ? color.from_gradient(comp, 0, 60, cMid, colBull) : color.from_gradient(comp, -60, 0, colBear, cMid)
barcolor(colorCandles ? compCol : na, title = "Candle colour")
// zones: soft gradient bands that fade outwards
pZU1 = plot(zoneLvl, "Upper zone", color = color.new(colBear, neo ? 65 : 50), linewidth = 1, display = display.pane)
pZU2 = plot(zoneLvl + 30, "Upper zone edge", color = na, display = display.none)
pZL1 = plot(-zoneLvl, "Lower zone", color = color.new(colBull, neo ? 65 : 50), linewidth = 1, display = display.pane)
pZL2 = plot(-zoneLvl - 30, "Lower zone edge", color = na, display = display.none)
fill(pZU2, pZU1, zoneLvl + 30, zoneLvl, color.new(colBear, 100), color.new(colBear, neo ? 88 : 94), title = "Upper zone fill")
fill(pZL1, pZL2, -zoneLvl, -zoneLvl - 30, color.new(colBull, neo ? 88 : 94), color.new(colBull, 100), title = "Lower zone fill")
hline(0, "Zero", color = color.new(cMuted, 60), linestyle = hline.style_dotted)
// gradient area under the line (strong near the line, fading to zero)
pZero = plot(0, "Zero base", color = na, display = display.none)
pPos = plot(math.max(comp, 0), "Area +", color = na, display = display.none)
pNeg = plot(math.min(comp, 0), "Area -", color = na, display = display.none)
fill(pPos, pZero, 60, 0, color.new(colBull, neo ? 45 : 80), color.new(colBull, 100), title = "Bull area")
fill(pZero, pNeg, 0, -60, color.new(colBear, 100), color.new(colBear, neo ? 45 : 80), title = "Bear area")
plot(neo ? na : comp, "Eye Composite histogram", color = color.new(compCol, 70), style = plot.style_columns, display = display.pane)
plot(comp, "Eye Composite", color = compCol, linewidth = 2)
// turning dots: composite peaks above the upper zone / troughs below the lower zone (shown on the turning bar)
topTurn = barstate.isconfirmed and comp[1] >= zoneLvl and comp[1] > comp[2] and comp[1] > comp
botTurn = barstate.isconfirmed and comp[1] <= -zoneLvl and comp[1] < comp[2] and comp[1] < comp
plot(neo and topTurn ? comp[1] : na, "Top turn", color = colBear, style = plot.style_circles, linewidth = 4, offset = -1, display = display.pane)
plot(neo and botTurn ? comp[1] : na, "Bottom turn", color = colBull, style = plot.style_circles, linewidth = 4, offset = -1, display = display.pane)
// entries
plotshape(neo and sigBull, "Bull glow (pane)", shape.circle, location.bottom, color.new(colBull, 65), size = size.small, display = display.pane)
plotshape(neo and sigBear, "Bear glow (pane)", shape.circle, location.top, color.new(colBear, 65), size = size.small, display = display.pane)
plotshape(sigBull, "Bullish entry (pane)", shape.triangleup, location.bottom, colBull, size = size.tiny, display = display.pane)
plotshape(sigBear, "Bearish entry (pane)", shape.triangledown, location.top, colBear, size = size.tiny, display = display.pane)
plotshape(neo and sigBull, "Bull glow (price)", shape.circle, location.belowbar, color.new(colBull, 65), size = size.small, force_overlay = true, display = display.pane)
plotshape(neo and sigBear, "Bear glow (price)", shape.circle, location.abovebar, color.new(colBear, 65), size = size.small, force_overlay = true, display = display.pane)
plotshape(sigBull, "Bullish entry (price)", shape.triangleup, location.belowbar, colBull, size = size.tiny, force_overlay = true, display = display.pane)
plotshape(sigBear, "Bearish entry (price)", shape.triangledown, location.abovebar, colBear, size = size.tiny, force_overlay = true, display = display.pane)
plot(sigBull ? 1 : sigBear ? -1 : 0, "Signal (+1 bull / -1 bear)", display = display.data_window)
plot(sigType >= 0 ? sig.score : na, "Signal score", display = display.data_window)
// ═════════════════════════ DASHBOARD ═════════════════════════
dashPos = switch dashPosIn
"Top Left" => position.top_left
"Bottom Right" => position.bottom_right
"Bottom Left" => position.bottom_left
=> position.top_right
var table dash = na
var bool merged = false
f_cell(table t, int c, int r, string s, color tc, color bg) =>
table.cell(t, c, r, s, text_color = tc, bgcolor = bg, text_size = size.small, text_halign = c == 0 ? text.align_left : text.align_center)
f_meter(float v) =>
int n = int(math.min(math.round(math.abs(v) / 12.0), 5))
string m = ""
for k = 1 to 5
m += k <= n ? "▰" : "▱"
m
if barstate.islast and showDash
if na(dash)
dash := dashOnPrice ? table.new(dashPos, 4, 6, border_color = neo ? color.new(cBg, 60) : color.new(chart.fg_color, 85), border_width = neo ? 2 : 1, frame_color = neo ? color.new(colBull, 35) : color.new(chart.fg_color, 70), frame_width = neo ? 2 : 1, force_overlay = true) : table.new(dashPos, 4, 6, border_color = neo ? color.new(cBg, 60) : color.new(chart.fg_color, 85), border_width = neo ? 2 : 1, frame_color = neo ? color.new(colBull, 35) : color.new(chart.fg_color, 70), frame_width = neo ? 2 : 1, force_overlay = false)
color fg = neo ? cText : chart.fg_color
color bg = neo ? color.new(cPanel, 55) : color.new(chart.bg_color, 50)
color bgH = neo ? color.new(cEdge, 40) : color.new(chart.fg_color, 90)
f_cell(dash, 0, 0, "Eye Divergence Engine", neo ? colBull : fg, bgH)
for c = 1 to 3
f_cell(dash, c, 0, "", fg, bgH)
string bias = comp > 20 ? "Bullish" : comp < -20 ? "Bearish" : "Neutral"
color bc = comp > 20 ? colBull : comp < -20 ? colBear : fg
f_cell(dash, 0, 1, "Eye Composite", fg, bg)
f_cell(dash, 1, 1, str.tostring(comp, "0") + " " + f_meter(comp), bc, bg)
f_cell(dash, 2, 1, "Bias", fg, bg)
f_cell(dash, 3, 1, bias, bc, bg)
bool hasLast = lastType >= 0
color lc = not hasLast ? fg : (lastType == 0 or lastType == 2) ? colBull : colBear
f_cell(dash, 0, 2, "Last entry", fg, bg)
f_cell(dash, 1, 2, hasLast ? array.get(typNames, lastType) : "–", lc, bg)
f_cell(dash, 2, 2, hasLast ? "Grade " + lastGrade + " · " + str.tostring(lastScore) + "/100" : "–", lc, bg)
f_cell(dash, 3, 2, hasLast ? str.tostring(bar_index - lastBar) + " bars ago" : "–", fg, bg)
string voters = ""
for j = 0 to 6
if f_hasBit(lastMask, j)
voters += (voters == "" ? "" : ", ") + array.get(oscNames, j)
f_cell(dash, 0, 3, "Voters", fg, bg)
f_cell(dash, 1, 3, hasLast ? str.tostring(lastVotes) + "/" + str.tostring(lastEnN) + " · " + voters : "–", fg, bg)
f_cell(dash, 0, 4, "Invalidation", fg, bg)
f_cell(dash, 1, 4, hasLast ? str.tostring(lastInv, format.mintick) + " (pivot)" : "–", fg, bg)
int nWait = array.size(pend)
string waitTxt = "–"
color wc = fg
if nWait > 0
Div w = array.get(pend, nWait - 1)
waitTxt := array.get(typNames, w.typ) + " · " + w.grade + " · close " + (w.dir == 1 ? "> " : "< ") + str.tostring(w.trig, format.mintick)
wc := w.dir == 1 ? colBull : colBear
f_cell(dash, 0, 5, "Waiting trigger", fg, bg)
f_cell(dash, 1, 5, waitTxt, wc, bg)
if not merged
table.merge_cells(dash, 0, 0, 3, 0)
table.merge_cells(dash, 1, 3, 3, 3)
table.merge_cells(dash, 1, 4, 3, 4)
table.merge_cells(dash, 1, 5, 3, 5)
merged := true
// ═════════════════════════ ALERTS ═════════════════════════
alertcondition(sigType == 0, "Regular Bullish Divergence entry", "Eye Divergence Engine: Regular Bullish entry triggered on {{ticker}} {{interval}}")
alertcondition(sigType == 1, "Regular Bearish Divergence entry", "Eye Divergence Engine: Regular Bearish entry triggered on {{ticker}} {{interval}}")
alertcondition(sigType == 2, "Hidden Bullish Divergence entry", "Eye Divergence Engine: Hidden Bullish entry triggered on {{ticker}} {{interval}}")
alertcondition(sigType == 3, "Hidden Bearish Divergence entry", "Eye Divergence Engine: Hidden Bearish entry triggered on {{ticker}} {{interval}}")
alertcondition(sigType >= 0 and sig.grade == "A", "Any A-grade Divergence entry", "Eye Divergence Engine: A-grade entry triggered on {{ticker}} {{interval}}")
if sigType >= 0
string voters = ""
for j = 0 to 6
if f_hasBit(sig.mask, j)
voters += (voters == "" ? "" : ", ") + array.get(oscNames, j)
alert("Eye Divergence Engine: " + array.get(typNames, sigType) + " entry | " + str.tostring(sig.votes) + "/" + str.tostring(enN) + " oscillators (" + voters + ") | Grade " + sig.grade + " " + str.tostring(sig.score) + " | " + syminfo.ticker + " " + timeframe.period + " | Close " + str.tostring(close, format.mintick), alert.freq_once_per_bar_close)