本页源码来自 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/
// © Choliszt
//
// Charge & Release Sequence
// 1. Charge — price goes quiet: the bands get unusually narrow. Dots count the quiet bars
// (from the 3rd quiet bar in a row, so single quiet bars don't clutter the chart).
// After enough quiet bars, a thick ribbon covers the whole range, with the count on top.
// The zone reaches back to where the sideways range really began and ignores stray wicks.
// 2. Release — the market wakes up (no longer quiet) and a candle closes outside the zone: ▲ or ▼.
// While price is still quiet, the zone simply stretches.
// 3. Expand — price reaches 1, 2 and 3 zone-heights beyond the zone: E1, E2, E3.
// The charge ribbon narrows and flows on, following the candles through every level reached.
// After a level is reached, the move is over once price gives back a full level.
// Fail — price closes past the middle of the zone before E1: FAIL. No ribbon is drawn.
// Targets ahead — while a zone is charging, E1/E2/E3 are already drawn on both sides with their
// prices. After the release the other side disappears; each level that is hit lights
// up with a check mark and the move in %. Levels are fixed at the release and never move.
// Charge meter — a small battery in the top-right corner fills up while price stays quiet.
// Grades — every release is tagged A+ or A.
// A+ = the market is already waking up: volatility of the last 14 bars is at least
// 0.9x that of the last 50 bars on the release candle. Solid tag.
// A = everything else. Faded tag.
// No repainting: every decision is made on a closed candle and every mark is printed on the
// candle where it happened. Shapes that reach back (the zone's left side, the ribbon) are drawn
// only from candles that had already closed.
//@version=6
indicator("Charge & Release Sequence", shorttitle="C&R Seq", overlay=true, max_lines_count=500, max_labels_count=500, max_polylines_count=100, max_bars_back=600)
// ════════════════════════════════════════════════════════════
// SETTINGS
// ════════════════════════════════════════════════════════════
gMain = "Settings"
minBars = input.int(6, "Quiet bars needed to charge", minval=2, group=gMain, tooltip="How many quiet bars in a row before a zone is drawn.")
showGr = input.bool(true, "Show grades (A / A+)", group=gMain, tooltip="A+ = the market is already waking up when the zone breaks. A = everything else.")
grWake = input.float(0.9, "A+: recent volatility at least (x normal)", minval=0.5, step=0.05, group=gMain, tooltip="Average range of the last 14 bars divided by that of the last 50 bars, on the release candle.")
showDots = input.bool(true, "Show charge dots", group=gMain)
showTgt = input.bool(true, "Show targets ahead", group=gMain, tooltip="Draw E1/E2/E3 on both sides while a zone is charging, then keep the side of the release.")
showMeter = input.bool(true, "Show charge meter", group=gMain, tooltip="Battery in the top-right corner: empty when nothing is charging, fills while price stays quiet.")
batFull = input.int(20, "Battery full at (bars)", minval=6, group=gMain, tooltip="How many bars of charge fill the battery.")
showStats = input.bool(true, "Show summary", group=gMain)
gAdv = "Advanced"
bbLen = input.int(20, "Band length", minval=5, group=gAdv)
bbMult = input.float(2.0, "Band width (std dev)", minval=0.5, step=0.1, group=gAdv)
lookback = input.int(120, "Compare with last (bars)", minval=20, group=gAdv, tooltip="A bar is quiet when its bands are narrower than most of this many past bars.")
quietPct = input.float(20, "Quiet = narrowest (%) of past bars", minval=1, maxval=50, group=gAdv)
expiry = input.int(30, "Charge expires after (bars)", minval=1, group=gAdv, tooltip="If price has not broken out this many bars after the quiet period ends, the zone is removed.")
dotMin = input.int(3, "Dots start after (quiet bars)", minval=1, group=gAdv, tooltip="Outside a zone, a dot is drawn only once price has been quiet this many bars in a row. Single quiet bars are ignored.")
ribW = input.float(1.0, "Ribbon width (x ATR)", minval=0.1, step=0.1, group=gAdv, tooltip="The ribbon is at least this wide, and never thinner than about a third of the zone, so it stays visible.")
gCol = "Colors"
cUp = input.color(#00E5FF, "Release up", group=gCol)
cDn = input.color(#FF4081, "Release down", group=gCol)
cChg = input.color(#FFC400, "Charge", group=gCol)
// ════════════════════════════════════════════════════════════
// QUIET BARS & MARKET ACTIVITY
// ════════════════════════════════════════════════════════════
basis = ta.sma(close, bbLen)
dev = bbMult * ta.stdev(close, bbLen)
bbw = basis != 0 ? 2 * dev / basis : na
rank = ta.percentrank(bbw, lookback)
quiet = not na(rank) and rank < quietPct
atr50 = ta.atr(50)
wake = ta.atr(14) / atr50
bodyT = math.max(open, close)
bodyB = math.min(open, close)
CLEAR = color.new(color.black, 100)
// ════════════════════════════════════════════════════════════
// SHAPES
// ════════════════════════════════════════════════════════════
// Candle edge (lows for an up move, highs for a down move), smoothed over closed candles only.
f_edgeAt(int o, int d) =>
float a = d == 1 ? low[o + 1] : high[o + 1]
float b = d == 1 ? low[o] : high[o]
float c = d == 1 ? low[math.max(o - 1, 0)] : high[math.max(o - 1, 0)]
d == 1 ? math.min(a, math.min(b, c)) : math.max(a, math.max(b, c))
f_smooth(int x, int d) =>
int o = bar_index - x
float s = 0.0
int n = 0
for k = -2 to 2
int oo = o + k
if oo >= 0
s += f_edgeAt(oo, d)
n += 1
s / n
type Move
int dir
float top
float bot
float mid
float h
float edge
float th
int bs // bar where the charge began
int relBar
int e1Bar
int e2Bar
int stage = 0
int grade = 1 // 1 = A, 2 = A+
bool show = true
polyline p1 // the whole shape
polyline p2 // shading layers (see f_draw)
polyline p3
line[] tl // target lines E1..E3
label[] tt // target price tags (removed when hit)
// Outline of one move: the thick charge part (flat top and bottom = the breakout levels, soft
// rounded head), then — once a level is reached — the release part, which eases out of the zone
// over 6 candles, follows the candles and opens up to the last level reached at its end.
// relBar = na or stage = 0 draws the charge part only. Built only from candles already closed.
f_geom(int bs, int relBar, int x1, int d, float top, float bot, float th, int stage) =>
int[] xs = array.new<int>()
float[] us = array.new<float>()
float[] ls = array.new<float>()
float H = top - bot
float mid = (top + bot) / 2
float edge = d == 1 ? top : bot
float gap = 0.15 * th
float lvl = edge + d * stage * H
bool rib = not na(relBar) and stage > 0
for x = bs to x1
float u = na
float l = na
if not rib or x < relBar
float tp = 0.3 + 0.7 * math.sin(math.min(1.0, (x - bs) / 4.0) * math.pi / 2)
u := mid + H / 2 * tp
l := mid - H / 2 * tp
else
float base = f_smooth(x, d) - d * gap
float w = 0.5 - 0.5 * math.cos(math.min(1.0, (x - relBar) / 6.0) * math.pi)
float near = x == x1 ? lvl : (1 - w) * edge + w * base
float far = (1 - w) * (edge - d * H) + w * (base - d * th)
u := d == 1 ? near : far
l := d == 1 ? far : near
array.push(xs, x)
array.push(us, u)
array.push(ls, l)
[xs, us, ls]
f_layer(int[] xs, float[] us, float[] ls, float a0, float a1, color col) =>
chart.point[] up = array.new<chart.point>()
chart.point[] dn = array.new<chart.point>()
for i = 0 to array.size(xs) - 1
int x = array.get(xs, i)
if x >= a0 and x <= a1
array.push(up, chart.point.from_index(x, array.get(us, i)))
array.unshift(dn, chart.point.from_index(x, array.get(ls, i)))
polyline p = na
if array.size(up) >= 2
array.concat(up, dn)
p := polyline.new(up, curved=true, closed=true, line_color=CLEAR, fill_color=col)
p
// Draws one move with shading that builds up through the charge (thirds of the zone), is
// strongest around the breakout, and steps lighter after E1 and again after E2.
f_draw(int bs, int relBar, int x1, int d, float top, float bot, float th, int stage, int e1Bar, int e2Bar, color col) =>
[xs, us, ls] = f_geom(bs, relBar, x1, d, top, bot, th, stage)
int rb = na(relBar) ? x1 : relBar
float len = rb - bs
int end2 = stage >= 2 ? e2Bar : x1
int end3 = stage >= 1 ? e1Bar : rb
polyline q1 = f_layer(xs, us, ls, bs, x1, color.new(col, 80))
polyline q2 = f_layer(xs, us, ls, bs + len / 3, end2, color.new(col, 87))
polyline q3 = f_layer(xs, us, ls, bs + 2 * len / 3, end3, color.new(col, 87))
[q1, q2, q3]
f_pctTxt(Move m, int k) =>
float pct = m.dir * k * m.h / m.edge * 100
(pct >= 0 ? "+" : "") + str.tostring(pct, "0.0") + "%"
// ════════════════════════════════════════════════════════════
// STATE
// ════════════════════════════════════════════════════════════
var int run = 0 // quiet bars in a row
var bool armed = false // a charge zone is waiting for a release
var float bTop = na
var float bBot = na
var int sinceEnd = 0
var int boxStart = na
var int lastEnd = -1
var float bodyHi = na
var float bodyLo = na
var float[] bxH = array.new<float>()
var float[] bxL = array.new<float>()
var polyline bxP1 = na // the waiting charge, redrawn each candle
var polyline bxP2 = na
var polyline bxP3 = na
var polyline[] shadeQ = array.new<polyline>() // shading layers of past moves (only the latest are kept)
var label bxLbl = na
var Move[] moves = array.new<Move>()
var line[] preL = array.new<line>() // targets drawn ahead while a zone is charging (up 1-3, down 1-3)
var label[] preT = array.new<label>()
var int lastConf = na
f_preClear() =>
for l in preL
line.delete(l)
for t in preT
label.delete(t)
array.clear(preL)
array.clear(preT)
var int nRel = 0
var int nE1 = 0
var int nE2 = 0
var int nE3 = 0
var int nFail = 0
var int[] nG = array.from(0, 0) // releases per grade (A, A+)
var int[] nGE1 = array.from(0, 0) // ... that reached E1 before FAIL
var int[] nGF = array.from(0, 0) // ... that failed first
bool evUp = false
bool evDn = false
bool evAP = false
bool evE1 = false
bool evFail = false
int dotRun = 0
// ════════════════════════════════════════════════════════════
// MAIN — closed candles only
// ════════════════════════════════════════════════════════════
if barstate.isconfirmed
lastConf := bar_index
// 1. Release: the market wakes up and closes outside a charged zone (built from earlier candles only)
int rel = 0
if armed and not quiet
rel := close > bTop ? 1 : close < bBot ? -1 : 0
if rel != 0
color dc = rel == 1 ? cUp : cDn
int gr = (not na(wake) and wake >= grWake) ? 2 : 1
// the zone takes the color of the breakout
polyline.delete(bxP1)
polyline.delete(bxP2)
polyline.delete(bxP3)
bxP1 := na
bxP2 := na
bxP3 := na
label.set_textcolor(bxLbl, color.new(dc, 10))
Move m = Move.new(dir=rel, top=bTop, bot=bBot, mid=(bTop + bBot) / 2, h=bTop - bBot, edge=rel == 1 ? bTop : bBot, th=math.max(ribW * atr50, 0.3 * (bTop - bBot)), bs=boxStart, relBar=bar_index, grade=gr, tl=array.new<line>(), tt=array.new<label>())
// the targets on the side of the release stay (fixed from here on), the other side goes
f_preClear()
if m.show and showTgt
for k = 1 to 3
float lv = m.edge + rel * k * m.h
array.push(m.tl, line.new(bar_index, lv, bar_index + 10, lv, color=color.new(dc, 45), style=line.style_dashed, width=1))
array.push(m.tt, label.new(bar_index + 10, lv, "E" + str.tostring(k) + " " + str.tostring(lv, format.mintick), yloc=yloc.price, style=label.style_label_left, color=CLEAR, textcolor=color.new(dc, 30), size=size.small))
[q1, q2, q3] = f_draw(boxStart, bar_index, bar_index, rel, bTop, bBot, m.th, 0, na, na, dc)
m.p1 := q1
m.p2 := q2
m.p3 := q3
array.push(shadeQ, q2)
array.push(shadeQ, q3)
if m.show
// A+: solid tag · A: faded tag
string gt = showGr ? (gr == 2 ? "A+ " : "A ") : ""
color bg = color.new(dc, showGr and gr == 1 ? 65 : 0)
color tx = showGr and gr == 1 ? color.white : rel == 1 ? color.black : color.white
label.new(bar_index, rel == 1 ? low : high, gt + (rel == 1 ? "▲" : "▼"), yloc=rel == 1 ? yloc.belowbar : yloc.abovebar, style=rel == 1 ? label.style_label_up : label.style_label_down, color=bg, textcolor=tx, size=size.small)
array.push(moves, m)
evUp := rel == 1
evDn := rel == -1
nRel += 1
evAP := gr == 2
array.set(nG, gr - 1, array.get(nG, gr - 1) + 1)
armed := false
run := 0
lastEnd := bar_index
// 2. Track every live move (an older move keeps going even if a new zone releases)
if array.size(moves) > 0
for i = array.size(moves) - 1 to 0
Move m = array.get(moves, i)
color dc = m.dir == 1 ? cUp : cDn
bool done = false
if bar_index > m.relBar
bool past = m.dir == 1 ? close < m.mid : close > m.mid
// targets not hit yet keep running a little ahead of price
if array.size(m.tl) > m.stage
for k = m.stage to array.size(m.tl) - 1
line.set_x2(array.get(m.tl, k), bar_index + 10)
label.set_x(array.get(m.tt, k), bar_index + 10)
if m.stage == 0 and past
if m.show
label.new(bar_index, m.dir == 1 ? high : low, "FAIL", yloc=m.dir == 1 ? yloc.abovebar : yloc.belowbar, style=m.dir == 1 ? label.style_label_down : label.style_label_up, color=color.new(color.gray, 45), textcolor=color.new(color.white, 10), size=size.tiny)
nFail += 1
array.set(nGF, m.grade - 1, array.get(nGF, m.grade - 1) + 1)
evFail := true
done := true
for l in m.tl
line.delete(l)
for t in m.tt
label.delete(t)
array.clear(m.tl)
else
int reach = 0
for k = 1 to 3
float lvl = m.edge + m.dir * k * m.h
if (m.dir == 1 and close >= lvl) or (m.dir == -1 and close <= lvl)
reach := k
if reach > m.stage
if m.stage < 1
nE1 += 1
evE1 := true
array.set(nGE1, m.grade - 1, array.get(nGE1, m.grade - 1) + 1)
if m.stage < 2 and reach >= 2
nE2 += 1
if m.stage < 3 and reach >= 3
nE3 += 1
int prev = m.stage
float lvR = m.edge + m.dir * reach * m.h
m.stage := reach
if m.show
// redraw the whole charge + release as one piece, up to this level
if reach >= 1 and na(m.e1Bar)
m.e1Bar := bar_index
if reach >= 2 and na(m.e2Bar)
m.e2Bar := bar_index
polyline.delete(m.p1)
polyline.delete(m.p2)
polyline.delete(m.p3)
[q1, q2, q3] = f_draw(m.bs, m.relBar, bar_index, m.dir, m.top, m.bot, m.th, m.stage, m.e1Bar, m.e2Bar, dc)
m.p1 := q1
m.p2 := q2
m.p3 := q3
array.push(shadeQ, q2)
array.push(shadeQ, q3)
// each level hit lights up: solid line up to here and a check mark with the move in %
for k = prev + 1 to reach
float lvK = m.edge + m.dir * k * m.h
if k <= array.size(m.tl)
line l = array.get(m.tl, k - 1)
line.set_x2(l, bar_index)
line.set_style(l, line.style_solid)
line.set_color(l, color.new(dc, 15))
label.delete(array.get(m.tt, k - 1))
label.new(bar_index, lvK, "✓ E" + str.tostring(k) + " " + f_pctTxt(m, k), yloc=yloc.price, style=label.style_label_left, color=color.new(dc, 82), textcolor=dc, size=size.small)
// after a level is reached, the move is over once price gives back a full level
float back = m.edge + m.dir * (m.stage - 1) * m.h
if m.stage == 3 or (m.stage >= 1 and (m.dir == 1 ? close < back : close > back)) or bar_index - m.relBar > 400
done := true
if done
// targets never reached stop where the move ended
if array.size(m.tl) > m.stage
for k = m.stage to array.size(m.tl) - 1
line l = array.get(m.tl, k)
line.set_x2(l, bar_index)
line.set_color(l, color.new(dc, 70))
label.delete(array.get(m.tt, k))
array.remove(moves, i)
// 3. Charge: count quiet bars and build the zone
if rel == 0
if quiet
run += 1
dotRun := run
if armed
// still quiet: the zone stretches to include this candle
array.push(bxH, high)
array.push(bxL, low)
bodyHi := math.max(bodyHi, bodyT)
bodyLo := math.min(bodyLo, bodyB)
sinceEnd := 0
else if run >= minBars
// The core is the last few quiet candles. Walk back over earlier candles whose
// bodies stay close to the core, to find where the sideways range really began.
float cHi = bodyT
float cLo = bodyB
for k = 1 to minBars - 1
cHi := math.max(cHi, bodyT[k])
cLo := math.min(cLo, bodyB[k])
float tol = 0.5 * math.max(cHi - cLo, 0.3 * atr50)
int off = minBars
while off <= 60 and bar_index - off > lastEnd and bodyT[off] <= cHi + tol and bodyB[off] >= cLo - tol
off += 1
array.clear(bxH)
array.clear(bxL)
bodyHi := cHi
bodyLo := cLo
for k = 0 to off - 1
array.push(bxH, high[k])
array.push(bxL, low[k])
bodyHi := math.max(bodyHi, bodyT[k])
bodyLo := math.min(bodyLo, bodyB[k])
boxStart := bar_index - off + 1
armed := true
sinceEnd := 0
bxLbl := label.new(boxStart, high, "", yloc=yloc.price, style=label.style_label_lower_left, color=CLEAR, textcolor=color.new(cChg, 10), size=size.small)
if armed
// edges ignore stray wicks (90th / 10th percentile) but always cover every candle body
bTop := math.max(array.percentile_linear_interpolation(bxH, 90), bodyHi)
bBot := math.min(array.percentile_linear_interpolation(bxL, 10), bodyLo)
label.set_y(bxLbl, bTop)
label.set_text(bxLbl, str.tostring(bar_index - boxStart + 1))
else
run := 0
if armed
sinceEnd += 1
if sinceEnd > expiry
// no breakout in time: the zone is removed
armed := false
lastEnd := bar_index
polyline.delete(bxP1)
polyline.delete(bxP2)
polyline.delete(bxP3)
bxP1 := na
bxP2 := na
bxP3 := na
label.delete(bxLbl)
f_preClear()
// redraw the waiting zone up to the current candle
if armed
polyline.delete(bxP1)
polyline.delete(bxP2)
polyline.delete(bxP3)
[q1, q2, q3] = f_draw(boxStart, na, bar_index, 1, bTop, bBot, atr50, 0, na, na, cChg)
bxP1 := q1
bxP2 := q2
bxP3 := q3
// targets ahead on both sides — they follow the zone while it is still charging
if showTgt
if array.size(preL) == 0
for i = 0 to 5
color c = i < 3 ? cUp : cDn
array.push(preL, line.new(bar_index, close, bar_index + 12, close, color=color.new(c, 55), style=line.style_dashed, width=1))
array.push(preT, label.new(bar_index + 12, close, "", yloc=yloc.price, style=label.style_label_left, color=CLEAR, textcolor=color.new(c, 35), size=size.small))
for i = 0 to 5
int d = i < 3 ? 1 : -1
int k = i % 3 + 1
float lv = (d == 1 ? bTop : bBot) + d * k * (bTop - bBot)
line.set_xy1(array.get(preL, i), bar_index, lv)
line.set_xy2(array.get(preL, i), bar_index + 12, lv)
label.set_xy(array.get(preT, i), bar_index + 12, lv)
label.set_text(array.get(preT, i), "E" + str.tostring(k) + " " + str.tostring(lv, format.mintick))
// Keep the shading of the latest moves only; older moves keep their main shape.
while array.size(shadeQ) > 40
polyline.delete(array.shift(shadeQ))
// Charge dots: brighter the longer price stays quiet
plotshape(showDots and dotRun > 0 and (dotRun >= dotMin or armed), "Charge dot", shape.circle, location.belowbar, color.new(cChg, math.max(0, 80 - dotRun * 10)), size=size.tiny)
// ════════════════════════════════════════════════════════════
// CHARGE METER
// ════════════════════════════════════════════════════════════
var table mt = table.new(position.top_right, 1, 2, bgcolor=color.new(color.black, 30), frame_color=color.new(cChg, 60), frame_width=1)
f_bat(int n, int need) =>
int f = math.min(10, int(math.round(10.0 * n / need)))
string s = ""
for i = 1 to 10
s += i <= f ? "█" : "░"
s
if showMeter and barstate.islast
table.clear(mt, 0, 0, 0, 1)
if armed
int n = lastConf - boxStart + 1
bool ready = n >= batFull
string st = ready ? "FULLY CHARGED" : "charging"
table.cell(mt, 0, 0, "⚡ CHARGE " + str.tostring(n), text_color=cChg, text_size=size.normal, text_halign=text.align_left)
table.cell(mt, 0, 1, f_bat(n, batFull) + " " + st, text_color=ready ? color.black : cChg, bgcolor=ready ? cChg : na, text_size=size.small, text_halign=text.align_left)
else if run > 0
table.cell(mt, 0, 0, "⚡ GETTING QUIET " + str.tostring(run), text_color=color.new(cChg, 30), text_size=size.normal, text_halign=text.align_left)
table.cell(mt, 0, 1, f_bat(run, batFull) + " zone at " + str.tostring(minBars) + " bars", text_color=color.new(cChg, 30), text_size=size.small, text_halign=text.align_left)
else
// nothing charging: the battery stays on screen, empty, so you know it is watching
table.cell(mt, 0, 0, "⚡ NO CHARGE", text_color=color.new(cChg, 55), text_size=size.normal, text_halign=text.align_left)
table.cell(mt, 0, 1, f_bat(0, batFull) + " waiting for a quiet market", text_color=color.new(cChg, 55), text_size=size.small, text_halign=text.align_left)
// ════════════════════════════════════════════════════════════
// SUMMARY
// ════════════════════════════════════════════════════════════
var table tb = table.new(position.bottom_right, 3, 5, bgcolor=color.new(color.black, 30), border_width=1, border_color=color.new(color.gray, 75), frame_color=color.new(color.gray, 60), frame_width=1)
f_cell(int c, int r, string t, color tc) =>
table.cell(tb, c, r, t, text_color=tc, text_size=size.small, text_halign=c == 0 ? text.align_left : text.align_right)
f_pct(int x, int n) =>
n == 0 ? "—" : str.tostring(100.0 * x / n, "0") + "%"
if showStats and barstate.islast
color tM = color.new(color.white, 40)
f_cell(0, 0, "Charge & Release", color.white)
f_cell(1, 0, "releases", tM)
f_cell(2, 0, "E1 before FAIL", tM)
for g = 1 to 0
int r = 2 - g
f_cell(0, r, g == 1 ? "A+" : "A", color.white)
f_cell(1, r, str.tostring(array.get(nG, g)), color.white)
f_cell(2, r, f_pct(array.get(nGE1, g), array.get(nGE1, g) + array.get(nGF, g)), color.white)
f_cell(0, 3, "All", tM)
f_cell(1, 3, str.tostring(nRel), tM)
f_cell(2, 3, f_pct(nE1, nE1 + nFail), tM)
f_cell(0, 4, "Went on to E2 / E3 (all)", tM)
f_cell(1, 4, "", tM)
f_cell(2, 4, f_pct(nE2, nE1 + nFail) + " / " + f_pct(nE3, nE1 + nFail), tM)
// ════════════════════════════════════════════════════════════
// ALERTS
// ════════════════════════════════════════════════════════════
alertcondition(evUp, "Release up", "Charge & Release: RELEASE ▲")
alertcondition(evDn, "Release down", "Charge & Release: RELEASE ▼")
alertcondition(evAP, "A+ release", "Charge & Release: A+ RELEASE")
alertcondition(evE1, "E1 reached", "Charge & Release: E1 reached")
alertcondition(evFail, "Fail", "Charge & Release: FAIL — price closed past the middle of the zone")
string aMsg = evAP ? (evUp ? "A+ RELEASE ▲" : "A+ RELEASE ▼") : evUp ? "RELEASE ▲" : evDn ? "RELEASE ▼" : evE1 ? "E1 reached" : evFail ? "FAIL" : ""
if aMsg != ""
alert(syminfo.ticker + " " + timeframe.period + " — " + aMsg + " @ " + str.tostring(close, format.mintick), alert.freq_once_per_bar)