Quantel iFVG & Breakout DetectorThe Quantel iFVG & Breakout Detector is a precision tool designed to highlight inversion fair value gaps (iFVGs) and breakout opportunities with crystal-clear visuals. It plots:
Arrow Signals – to mark breakout confirmations.
Box Highlights – to show active iFVG zones and breakout ranges.
💡 How to Use:
Use the arrows as directional cues for potential entries after a confirmed breakout.
Watch the highlighted boxes to identify imbalances and zones of interest for reversals or continuation.
Best combined with liquidity sweeps, BOS/CHOCH, or higher timeframe bias for stronger confirmation.
✅ Features:
Automatic detection of iFVGs with dynamic zone plotting.
Breakout confirmation arrows for easy trade visualization.
Clean, uncluttered chart display suitable for all timeframes.
⚠️ Disclaimer: This tool is for educational purposes only. Not financial advice. Always combine signals with your own trading plan and risk management.
Analizy Trendu
ELLIOT WAVE TP11OFC5//@version=6
indicator("TP11OFC5", overlay=true, scale=scale.right, max_lines_count=500, max_labels_count=500, max_boxes_count=500, max_bars_back=5000)
//──────────────────────────────── Inputs: Masked Names ───────────────────────────────
// yelow group (EMA200 + 5up/5down)
group200 = "yelow group"
emaLen200 = input.int(200, "yelow length", minval=1, group=group200)
show200Mid = input.bool(true, "show big brown", group=group200) // EMA200 mid
show200_5u = input.bool(true, "show yelow group up", group=group200) // 5up (EMA200)
show200_5d = input.bool(true, "show yelow group down",group=group200) // 5down (EMA200)
// Colors (masked)
groupClrMA = "Colors — lines"
colMid200 = input.color(color.rgb(100, 50, 0), "big brown", group=groupClrMA) // EMA200 mid
col5band = input.color(color.rgb(247, 212, 14), "yelow up/down", group=groupClrMA) // 5up/5down
col85_4 = input.color(color.rgb(9, 77, 202), "blue up/down (x4)",group=groupClrMA) // EMA85 4up/4down
col35 = input.color(color.rgb(7, 9, 155), "big blue", group=groupClrMA) // EMA35
colPNR = input.color(color.rgb(255,17,0), "pn", group=groupClrMA) // PNR
// blue group (EMA85 — 4 up/down)
group85 = "blue group"
emaLen85 = input.int(85, "blue length", minval=1, group=group85)
show85_4u = input.bool(true, "show blue group up", group=group85)
show85_4d = input.bool(true, "show blue group down", group=group85)
// big blue (EMA35)
group35 = "big blue"
emaLen35 = input.int(35, "big blue length", minval=1, group=group35)
useClose35 = input.bool(false, "big blue use close (else effClose)", group=group35)
showEMA35 = input.bool(true, "show big blue", group=group35)
// pn (PNR)
groupPNR = "pn"
pnrLen = input.int(15, "window size", minval=1, group=groupPNR)
pnrPerc = input.int(50, "percentile (0–100)", minval=0, maxval=100, group=groupPNR)
pnrSrc = input.source(close, "source", group=groupPNR)
showPNR = input.bool(true, "show pn", group=groupPNR)
// di (DSI)
groupDSI = "di"
showDSI = input.bool(true, "show di", group=groupDSI)
atrMovement= input.float(1.0, "movement required", step=0.5, group=groupDSI)
lookback = input.int(25, "high/low lookback", step=5, group=groupDSI)
maxZoneSize= input.float(2.5, "max zone size ", step=0.5, group=groupDSI)
newStructureReset = input.int(25, "zone update count before reset", step=5, group=groupDSI)
drawPreviousStructure = input.bool(true, "draw previous zones", group=groupDSI)
groupClrDSI = "Colors — zones"
dsiBullColor = input.color(color.rgb(178, 240, 180), "bull color", group=groupClrDSI)
dsiBearColor = input.color(color.rgb(240, 206, 206), "bear color", group=groupClrDSI)
//──────────────────────────────── FE (Trend-base Fibo) ───────────────────────────────
groupFE = "targets — FE"
feLenBars = input.int(35, "FE length (bars) from P3", minval=5, group=groupFE)
feLife = input.int(500, "FE lifespan (bars) before delete", minval=50, group=groupFE)
showFE = input.bool(true, "show FE", group=groupFE)
roundToTick = input.bool(true, "round FE to tick", group=groupFE)
// FE levels on/off
show95_105 = input.bool(true, "show band", group=groupFE)
show1618 = input.bool(true, "show 1", group=groupFE)
show2618 = input.bool(true, "show 2", group=groupFE)
show3618 = input.bool(true, "show 3", group=groupFE)
show4618 = input.bool(true, "show 4", group=groupFE)
// FE colors
colBand = input.color(color.rgb(79, 247, 46), "line", group=groupFE)
colBandFill = input.color(color.new(#8be95f, 85), "band", group=groupFE)
col1618 = input.color(color.orange, "1line", group=groupFE)
col2618 = input.color(color.fuchsia, "2line", group=groupFE)
col3618 = input.color(color.new(color.purple, 0), "3line", group=groupFE)
col4618 = input.color(color.new(color.maroon, 0), "4line", group=groupFE)
//──────────────────────────────── P-series (เดิม) ───────────────────────────────
groupP1P2P3 = "P-series options"
p1Lookback = input.int(200, "P1 max left scan", minval=20, group=groupP1P2P3)
rightWinBars = input.int(5, "P2 right confirm bars", minval=1, group=groupP1P2P3)
p3MaxWindowBars = input.int(600, "P3 max window (bars)", minval=50, maxval=5000, step=50, group=groupP1P2P3)
resetWithinBars = input.int(50, "reset old set if new within (bars)", minval=1, group=groupP1P2P3)
// >>> NEW: ระยะห่างขั้นต่ำ P1/P3 จาก P2 <<<
minGapBars = input.int(5, "Min gap bars: P1/P3 must be at least this far from P2", minval=1, group=groupP1P2P3)
// ── NEW: De-duplicate labels (no same-type within N bars; keep latest) ─────────────
groupDeDup = "Labels — de-dup"
dedupWinBars = input.int(50, "No same-type label within N bars", minval=1, group=groupDeDup)
// ──────────────────────────────── New: P2 window rule ───────────────────────────────
groupP2Win = "P2 window rule"
p2NewWithinBars = input.int(50, "Window N bars: new P2 within N must be better than last P2 (L: higher / S: lower)", minval=1, group=groupP2Win)
//──────────────────────────────── Visual options ───────────────────────────────
groupPviz = "Visual — Body highlights & labels"
showBodyBoxes = input.bool(true, "show body boxes", group=groupPviz)
P1BoxFullCandle = input.bool(false, "P1: full candle box", group=groupPviz)
P2BoxFullCandle = input.bool(false, "P2: full candle box", group=groupPviz)
P3BoxFullCandle = input.bool(false, "P3: full candle box", group=groupPviz)
P1BoxColor = input.color(color.black, "P1 box color", group=groupPviz)
P1BoxFillTransp = input.int(85, "P1 box fill transp", minval=0, maxval=100, group=groupPviz)
P2BoxColor = input.color(color.lime, "P2 box color", group=groupPviz)
P2BoxFillTransp = input.int(70, "P2 box fill transp", minval=0, maxval=100, group=groupPviz)
P3BoxColor = input.color(color.orange, "P3 box color", group=groupPviz)
P3BoxFillTransp = input.int(70, "P3 box fill transp", minval=0, maxval=100, group=groupPviz)
BoxBorderTransp = input.int(0, "box border transp", minval=0, maxval=100, group=groupPviz)
recolorBars = input.bool(true, "barcolor P1/P2/P3", group=groupPviz)
colP1Candle = input.color(color.black, "P1 candle", group=groupPviz)
colP2Candle = input.color(color.lime, "P2 candle", group=groupPviz)
colP3Candle = input.color(color.orange,"P3 candle", group=groupPviz)
showP1Label = input.bool(true, "show P1 label", group=groupPviz)
showP2Label = input.bool(true, "show P2 label", group=groupPviz)
showP3Label = input.bool(true, "show P3 label", group=groupPviz)
PLabelTextColor = input.color(color.white, "label text color", group=groupPviz)
PLabelBgColor = input.color(color.black, "label bg color", group=groupPviz)
// ── Label placement/offset (split LONG/SHORT) ───────────────────────────────
groupLbl = "Labels — placement"
LP_AUTO = "Auto"
LP_ABOVE = "Above"
LP_BELOW = "Below"
OM_TICKS = "Ticks"
OM_ATR = "ATR"
lblPlaceLong = input.string(LP_ABOVE, "Placement (LONG)", options= , group=groupLbl)
lblPlaceShort = input.string(LP_BELOW, "Placement (SHORT)", options= , group=groupLbl)
lblOffsetMet = input.string(OM_ATR, "Offset method", options= , group=groupLbl)
lblTicks = input.int(5, "Ticks offset", minval=0, group=groupLbl)
lblAtrLen = input.int(14, "ATR length", minval=1, group=groupLbl)
lblAtrMult = input.float(0.25, "ATR multiple", minval=0.0, step=0.05, group=groupLbl)
lblSizeSel = input.string("small", "Label size", options= , group=groupLbl)
lblBgTransp = input.int(0, "Label BG transparency", minval=0, maxval=100, group=groupLbl)
//──────────────────────────────── Manual (แทน Override) ─────────────────────────
PM_OPEN = "Open"
PM_CLOSE = "Close"
PM_MID = "Mid"
PM_HIGH = "High"
PM_LOW = "Low"
PM_CUST = "Custom"
PK_TIME = "Time"
PK_OFF = "Offset"
// LONG
groupManL = "Manual (LONG)"
useManP1L = input.bool(false, "Use P1 manual (L)", group=groupManL)
pickP1L = input.string(PK_TIME, "P1 pick mode (L)", options= , group=groupManL)
manP1L_t = input.time(timestamp("01 Jan 2024 00:00 +0000"), "P1 time (L)", group=groupManL)
manP1L_of = input.int(-5, "P1 offset (bars, L)", group=groupManL)
pmP1L = input.string(PM_OPEN, "P1 price mode (L)", options= , group=groupManL)
p1L_custom= input.float(0.0, "P1 custom price (L)", group=groupManL)
useManP2L = input.bool(false, "Use P2 manual (L)", group=groupManL)
pickP2L = input.string(PK_TIME, "P2 pick mode (L)", options= , group=groupManL)
manP2L_t = input.time(timestamp("01 Jan 2024 00:00 +0000"), "P2 time (L)", group=groupManL)
manP2L_of = input.int(-3, "P2 offset (bars, L)", group=groupManL)
pmP2L = input.string(PM_CLOSE, "P2 price mode (L)", options= , group=groupManL)
p2L_custom= input.float(0.0, "P2 custom price (L)", group=groupManL)
useManP3L = input.bool(false, "Use P3 manual (L)", group=groupManL)
pickP3L = input.string(PK_TIME, "P3 pick mode (L)", options= , group=groupManL)
manP3L_t = input.time(timestamp("01 Jan 2024 00:00 +0000"), "P3 time (L)", group=groupManL)
manP3L_of = input.int(-1, "P3 offset (bars, L)", group=groupManL)
pmP3L = input.string(PM_OPEN, "P3 price mode (L)", options= , group=groupManL)
p3L_custom= input.float(0.0, "P3 custom price (L)", group=groupManL)
// SHORT
groupManS = "Manual (SHORT)"
useManP1S = input.bool(false, "Use P1 manual (S)", group=groupManS)
pickP1S = input.string(PK_TIME, "P1 pick mode (S)", options= , group=groupManS)
manP1S_t = input.time(timestamp("01 Jan 2024 00:00 +0000"), "P1 time (S)", group=groupManS)
manP1S_of = input.int(-5, "P1 offset (bars, S)", group=groupManS)
pmP1S = input.string(PM_OPEN, "P1 price mode (S)", options= , group=groupManS)
p1S_custom= input.float(0.0, "P1 custom price (S)", group=groupManS)
useManP2S = input.bool(false, "Use P2 manual (S)", group=groupManS)
pickP2S = input.string(PK_TIME, "P2 pick mode (S)", options= , group=groupManS)
manP2S_t = input.time(timestamp("01 Jan 2024 00:00 +0000"), "P2 time (S)", group=groupManS)
manP2S_of = input.int(-3, "P2 offset (bars, S)", group=groupManS)
pmP2S = input.string(PM_CLOSE, "P2 price mode (S)", options= , group=groupManS)
p2S_custom= input.float(0.0, "P2 custom price (S)", group=groupManS)
useManP3S = input.bool(false, "Use P3 manual (S)", group=groupManS)
pickP3S = input.string(PK_TIME, "P3 pick mode (S)", options= , group=groupManS)
manP3S_t = input.time(timestamp("01 Jan 2024 00:00 +0000"), "P3 time (S)", group=groupManS)
manP3S_of = input.int(-1, "P3 offset (bars, S)", group=groupManS)
pmP3S = input.string(PM_OPEN, "P3 price mode (S)", options= , group=groupManS)
p3S_custom= input.float(0.0, "P3 custom price (S)", group=groupManS)
// Buttons: Reset (UI switches)
groupBtnL = "Manual Controls — Buttons (LONG)"
btnResetAllL = input.bool(false, "Reset ALL manual (L)", group=groupBtnL)
btnResetP1L = input.bool(false, "Reset P1 manual (L)", group=groupBtnL)
btnResetP2L = input.bool(false, "Reset P2 manual (L)", group=groupBtnL)
btnResetP3L = input.bool(false, "Reset P3 manual (L)", group=groupBtnL)
groupBtnS = "Manual Controls — Buttons (SHORT)"
btnResetAllS = input.bool(false, "Reset ALL manual (S)", group=groupBtnS)
btnResetP1S = input.bool(false, "Reset P1 manual (S)", group=groupBtnS)
btnResetP2S = input.bool(false, "Reset P2 manual (S)", group=groupBtnS)
btnResetP3S = input.bool(false, "Reset P3 manual (S)", group=groupBtnS)
// ── Momentary Reset (edge-detect) ───────────────────────────────
var bool resetReqAllL = false
var bool resetReqP1L = false
var bool resetReqP2L = false
var bool resetReqP3L = false
var bool resetReqAllS = false
var bool resetReqP1S = false
var bool resetReqP2S = false
var bool resetReqP3S = false
bool fireAllL = ta.change(btnResetAllL) and btnResetAllL
bool fireP1L = ta.change(btnResetP1L) and btnResetP1L
bool fireP2L = ta.change(btnResetP2L) and btnResetP2L
bool fireP3L = ta.change(btnResetP3L) and btnResetP3L
bool fireAllS = ta.change(btnResetAllS) and btnResetAllS
bool fireP1S = ta.change(btnResetP1S) and btnResetP1S
bool fireP2S = ta.change(btnResetP2S) and btnResetP2S
bool fireP3S = ta.change(btnResetP3S) and btnResetP3S
if fireAllL
resetReqAllL := true
resetReqP1L := true
resetReqP2L := true
resetReqP3L := true
if fireP1L
resetReqP1L := true
if fireP2L
resetReqP2L := true
if fireP3L
resetReqP3L := true
if fireAllS
resetReqAllS := true
resetReqP1S := true
resetReqP2S := true
resetReqP3S := true
if fireP1S
resetReqP1S := true
if fireP2S
resetReqP2S := true
if fireP3S
resetReqP3S := true
//──────────────────────────────── Core helpers ───────────────────────────────
float effClose = close >= open ? math.max(open, close) : math.min(open, close)
f_bodyTop(_o, _c) => math.max(_o, _c)
f_bodyBot(_o, _c) => math.min(_o, _c)
f_midBody_at(_i) =>
float bt = f_bodyTop(open , close )
float bb = f_bodyBot(open , close )
(bt + bb) / 2.0
f_core(_len) =>
float mid = ta.ema(effClose, _len)
float _dev = ta.stdev(effClose, _len)
float devS = _dev == 0.0 ? na : _dev
float plus = na(mid) or na(devS) ? na : (close > mid ? (close - mid) / devS : 0.0)
float minus = na(mid) or na(devS) ? na : (close < mid ? (mid - close) / devS : 0.0)
float mmax = na(plus) or na(minus) ? na : math.max(plus, minus)
float lm = ta.ema(mmax, _len)
f_core_src(_src, _len) =>
float mid = ta.ema(_src, _len)
float _dev = ta.stdev(_src, _len)
float devS = _dev == 0.0 ? na : _dev
float plus = na(mid) or na(devS) ? na : (_src > mid ? (_src - mid) / devS : 0.0)
float minus = na(mid) or na(devS) ? na : (_src < mid ? (mid - _src) / devS : 0.0)
float mmax = na(plus) or na(minus) ? na : math.max(plus, minus)
float lm = ta.ema(mmax, _len)
// Price by mode
f_price_by_mode(off, mode, custom) =>
switch mode
PM_OPEN => open
PM_CLOSE => close
PM_MID => (math.max(open , close ) + math.min(open , close ))/2.0
PM_HIGH => high
PM_LOW => low
PM_CUST => custom > 0 ? (roundToTick ? math.round(custom / syminfo.mintick) * syminfo.mintick : custom) : na
=> na
// NEW: Gap helpers
f_gap_ok_left(p1Abs, p2Abs) =>
not na(p1Abs) and not na(p2Abs) and (p2Abs - p1Abs) >= minGapBars
f_gap_ok_right(p3Abs, p2Abs) =>
not na(p3Abs) and not na(p2Abs) and (p3Abs - p2Abs) >= minGapBars
//──────────────────────────────── yelow group (EMA200 + 5up/5down) ───────────────────
= f_core_src(close, emaLen200)
phi_adj = 1.38196601
float fiveUp_200 = na(mid200) or na(dev200) or na(lm200) ? na : mid200 + (lm200 * phi_adj) * dev200
float fiveDown_200 = na(mid200) or na(dev200) or na(lm200) ? na : mid200 - (lm200 * phi_adj) * dev200
plot(show200_5d ? fiveDown_200 : na, title="yelow group down", color=col5band, linewidth=3)
plot(show200Mid ? mid200 : na, title="big brown", color=colMid200, linewidth=3)
plot(show200_5u ? fiveUp_200 : na, title="yelow group up", color=col5band, linewidth=3)
//──────────────────────────────── blue group (EMA85 — 4 up/down) ────────────────────
= f_core(emaLen85)
float up4_85 = na(mid85) or na(dev85) or na(lm85) ? na : mid85 + lm85 * dev85
float down4_85 = na(mid85) or na(dev85) or na(lm85) ? na : mid85 - lm85 * dev85
float fiveUp_85 = na(mid85) or na(dev85) or na(lm85) ? na : mid85 + (lm85 * phi_adj) * dev85
float fiveDown_85 = na(mid85) or na(dev85) or na(lm85) ? na : mid85 - (lm85 * phi_adj) * dev85
plot(show85_4u ? up4_85 : na, title="blue group up", color=col85_4, linewidth=2)
plot(show85_4d ? down4_85 : na, title="blue group down", color=col85_4, linewidth=2)
// big blue (EMA35)
float ema35 = useClose35 ? ta.ema(close, emaLen35) : ta.ema(effClose, emaLen35)
plot(showEMA35 ? ema35 : na, title="big blue", color=col35, linewidth=2)
// pn (PNR)
float pnr = na
if bar_index >= pnrLen - 1
float win = array.new_float()
for i = 0 to pnrLen - 1
array.push(win, pnrSrc )
array.sort(win)
float rankF = (pnrPerc / 100.0) * (pnrLen - 1)
int idx = int(math.round(rankF))
idx := math.max(0, math.min(idx, pnrLen - 1))
pnr := array.get(win, idx)
plot(showPNR ? pnr : na, title="pn", color=colPNR, linewidth=2)
//──────────────────────────────── Masked EMA Clouds (line 1–5) ───────────────────────
groupCloud = "line clouds"
showClouds = input.bool(true, "show lines clouds", group=groupCloud)
l1Len = input.int(5, "line 1 length", minval=1, group=groupCloud)
l2Len = input.int(8, "line 2 length", minval=1, group=groupCloud)
l3Len = input.int(21, "line 3 length", minval=1, group=groupCloud)
l4Len = input.int(34, "line 4 length", minval=1, group=groupCloud)
l5Len = input.int(50, "line 5 length", minval=1, group=groupCloud)
cloudUpColor = input.color(color.green, "cloud up color", group=groupCloud)
cloudDnColor = input.color(color.red, "cloud down color", group=groupCloud)
cloudTransp = input.int(60, "cloud transparency (0–100)", minval=0, maxval=100, group=groupCloud)
l1 = ta.ema(close, l1Len)
l2 = ta.ema(close, l2Len)
l3 = ta.ema(close, l3Len)
l4 = ta.ema(close, l4Len)
l5 = ta.ema(close, l5Len)
// พล็อตเส้นพราง (transp=100) และใช้ชื่อ line 1..5
p1 = plot(showClouds ? l1 : na, color=color.new(color.gray, 100), style=plot.style_line, linewidth=1, title="line 1")
p2 = plot(showClouds ? l2 : na, color=color.new(color.gray, 100), style=plot.style_line, linewidth=1, title="line 2")
p3 = plot(showClouds ? l3 : na, color=color.new(color.gray, 100), style=plot.style_line, linewidth=1, title="line 3")
p4 = plot(showClouds ? l4 : na, color=color.new(color.gray, 100), style=plot.style_line, linewidth=1, title="line 4")
p5 = plot(showClouds ? l5 : na, color=color.new(color.gray, 100), style=plot.style_line, linewidth=1, title="line 5")
// เรียก fill ที่ "global scope" แล้วคุมการแสดงผลด้วยสี (ถ้าไม่โชว์ให้ทำเป็นโปร่งใส)
cloud23Color = showClouds ? (l2 > l3 ? color.new(cloudUpColor, cloudTransp) : color.new(cloudDnColor, cloudTransp)) : color.new(color.black, 100)
cloud45Color = showClouds ? (l4 > l5 ? color.new(cloudUpColor, cloudTransp) : color.new(cloudDnColor, cloudTransp)) : color.new(color.black, 100)
fill(p2, p3, color=cloud23Color, title="cloud 2–3")
fill(p4, p5, color=cloud45Color, title="cloud 4–5")
//──────────────────────────────── Utilities ───────────────────────────────
isGreen_at(i) => close > open
isRed_at(i) => close < open
bodyTop_at(i) => f_bodyTop(open , close )
f_frac_body_above_line(i, lineV) =>
float bt = bodyTop_at(i), bb = f_bodyBot(open , close )
float body = bt - bb
body <= 0 or na(lineV) ? 0.0 : math.max(0.0, bt - math.max(bb, lineV)) / body
f_frac_body_below_line(i, lineV) =>
float bt = bodyTop_at(i), bb = f_bodyBot(open , close )
float body = bt - bb
body <= 0 or na(lineV) ? 0.0 : math.max(0.0, math.min(bt, lineV) - bb) / body
// Draw helpers
var box PBOXES = array.new_box()
var label PLABELS = array.new_label()
f_delete_boxes(box arr) =>
int n = array.size(arr)
for k = 0 to n - 1
int i = n - 1 - k
box.delete(array.get(arr, i))
array.clear(arr)
f_delete_labels(label arr) =>
int n = array.size(arr)
for k = 0 to n - 1
int i = n - 1 - k
label.delete(array.get(arr, i))
array.clear(arr)
// size mapper
f_lbl_size(s) =>
s == "tiny" ? size.tiny : s == "large" ? size.large : s == "normal" ? size.normal : size.small
// helper: one-line label.new
f_make_label(_x, _y, _text, _placeAbove) =>
label.new(_x, _y, _text, xloc=xloc.bar_time, style=(_placeAbove ? label.style_label_down : label.style_label_up), textcolor=PLabelTextColor, color=color.new(PLabelBgColor, lblBgTransp), size=f_lbl_size(lblSizeSel))
// smarter label placement (split LONG/SHORT) → return handles
f_add_label_ret(_abs, _text, _isLong) =>
label lb = na
int off = bar_index - _abs
if off >= 0 and off <= 5000 and not na(time ) and not na(high ) and not na(low )
float pad = lblOffsetMet == OM_TICKS ? (syminfo.mintick * lblTicks) : (ta.atr(lblAtrLen) * lblAtrMult)
string opt = _isLong ? lblPlaceLong : lblPlaceShort
bool placeAbove = (opt == LP_ABOVE) ? true : (opt == LP_BELOW) ? false : (close >= open )
float yPos = placeAbove ? (high + pad) : (low - pad)
lb := f_make_label(time , yPos, _text, placeAbove)
array.push(PLABELS, lb)
if array.size(PLABELS) > 500
label.delete(array.get(PLABELS, 0))
array.remove(PLABELS, 0)
lb
// draw mark → return
f_draw_mark_group(_abs, _full, _boxCol, _fillT, _borderT, _labelOn, _labelText, _isLong) =>
box nb = na
label lb = na
if not na(_abs)
int off = bar_index - _abs
if off >= 0 and off <= 5000
float top = _full ? high : bodyTop_at(off)
float bot = _full ? low : f_bodyBot(open , close )
if showBodyBoxes
nb := box.new(math.max(0, int(_abs) - 1), math.max(top, bot), int(_abs), math.min(top, bot), xloc=xloc.bar_index, bgcolor=color.new(_boxCol, _fillT), border_color=color.new(_boxCol, _borderT))
array.push(PBOXES, nb)
if array.size(PBOXES) > 500
box.delete(array.get(PBOXES, 0))
array.remove(PBOXES, 0)
if _labelOn
lb := f_add_label_ret(_abs, _labelText, _isLong)
//───────────────────── De-dup helpers (keep latest; delete older within window) ─────
f_del_if_exists(_bx, _lb) =>
if not na(_bx)
box.delete(_bx)
if not na(_lb)
label.delete(_lb)
// Strict int for last Abs to avoid NA-type errors
var int L_lastP1Abs = int(na)
var int L_lastP2Abs = int(na)
var int L_lastP3Abs = int(na)
var int S_lastP1Abs = int(na)
var int S_lastP2Abs = int(na)
var int S_lastP3Abs = int(na)
// IMPORTANT: declare one per line to keep type info on all variables
var box L_lastP1Box = na
var box L_lastP2Box = na
var box L_lastP3Box = na
var box S_lastP1Box = na
var box S_lastP2Box = na
var box S_lastP3Box = na
var label L_lastP1Lbl = na
var label L_lastP2Lbl = na
var label L_lastP3Lbl = na
var label S_lastP1Lbl = na
var label S_lastP2Lbl = na
var label S_lastP3Lbl = na
// >>> NEW: true-last P2 trackers (separate from de-dup) <<<
var int L_prevP2Abs = int(na)
var float L_prevP2Close = na
var int S_prevP2Abs = int(na)
var float S_prevP2Close = na
// enforce unique per type & side
f_enforce_and_set(_newAbs, _newBox, _newLbl, _lastAbs, _lastBox, _lastLbl) =>
bool keepNew = true
int lastAbsNew = _lastAbs
box lastBoxNew = _lastBox
label lastLblNew = _lastLbl
if not na(_lastAbs) and math.abs(_newAbs - _lastAbs) <= dedupWinBars
if _newAbs > _lastAbs
f_del_if_exists(_lastBox, _lastLbl)
lastAbsNew := _newAbs
lastBoxNew := _newBox
lastLblNew := _newLbl
else
f_del_if_exists(_newBox, _newLbl)
keepNew := false
else
lastAbsNew := _newAbs
lastBoxNew := _newBox
lastLblNew := _newLbl
//──────────────────────────────── FE helpers ───────────────────────────────
f_rt(v) => roundToTick ? math.round(v / syminfo.mintick) * syminfo.mintick : v
var line FE_l95 = array.new_line()
var line FE_l105 = array.new_line()
var line FE_l161 = array.new_line()
var line FE_l261 = array.new_line()
var line FE_l361 = array.new_line()
var line FE_l461 = array.new_line()
var linefill FE_fill = array.new_linefill()
var int FE_born = array.new_int()
f_delete_fe_index(idx) =>
int nAll = array.size(FE_born)
if idx >= 0 and idx < nAll
if idx < array.size(FE_fill)
linefill.delete(array.get(FE_fill, idx))
if idx < array.size(FE_l95)
line.delete(array.get(FE_l95, idx))
if idx < array.size(FE_l105)
line.delete(array.get(FE_l105, idx))
if idx < array.size(FE_l161)
line.delete(array.get(FE_l161, idx))
if idx < array.size(FE_l261)
line.delete(array.get(FE_l261, idx))
if idx < array.size(FE_l361)
line.delete(array.get(FE_l361, idx))
if idx < array.size(FE_l461)
line.delete(array.get(FE_l461, idx))
if idx < array.size(FE_l95)
array.remove(FE_l95, idx)
if idx < array.size(FE_l105)
array.remove(FE_l105, idx)
if idx < array.size(FE_l161)
array.remove(FE_l161, idx)
if idx < array.size(FE_l261)
array.remove(FE_l261, idx)
if idx < array.size(FE_l361)
array.remove(FE_l361, idx)
if idx < array.size(FE_l461)
array.remove(FE_l461, idx)
if idx < array.size(FE_fill)
array.remove(FE_fill, idx)
array.remove(FE_born, idx)
f_clear_all_fe() =>
int n = array.size(FE_born)
for k = 0 to n - 1
int i = n - 1 - k
f_delete_fe_index(i)
// ───────────── ADD: helper แปลง bar-abs → time (ms) ─────────────
f_abs_to_time(_abs) =>
if na(_abs)
na
else
int off = bar_index - _abs
if off < 0
na
else
int tfms = timeframe.in_seconds(timeframe.period) * 1000
off <= 5000 ? time : (time - off * tfms)
// ───────────── REPLACE: f_add_fe_set เดิม ด้วยเวอร์ชันกัน error ─────────────
f_add_fe_set(p3Abs, y95, y105, y161, y261, y361, y461) =>
int off = bar_index - p3Abs
bool useTime = off > 4500
int tfms = timeframe.in_seconds(timeframe.period) * 1000
color c95 = show95_105 ? colBand : color.new(colBand, 100)
color c105 = show95_105 ? colBand : color.new(colBand, 100)
color c161 = show1618 ? col1618 : color.new(col1618, 100)
color c261 = show2618 ? col2618 : color.new(col2618, 100)
color c361 = show3618 ? col3618 : color.new(col3618, 100)
color c461 = show4618 ? col4618 : color.new(col4618, 100)
// <<< แก้ไขตรงนี้: ประกาศตัวแปร line ทีละบรรทัด >>>
line l95 = na
line l105 = na
line l161 = na
line l261 = na
line l361 = na
line l461 = na
linefill lf = na
if not useTime
int x1 = p3Abs
int x2 = p3Abs + feLenBars
l95 := line.new(x1, y95, x2, y95, xloc=xloc.bar_index, extend=extend.none, color=c95, width=3)
l105 := line.new(x1, y105, x2, y105, xloc=xloc.bar_index, extend=extend.none, color=c105, width=3)
l161 := line.new(x1, y161, x2, y161, xloc=xloc.bar_index, extend=extend.none, color=c161, width=2)
l261 := line.new(x1, y261, x2, y261, xloc=xloc.bar_index, extend=extend.none, color=c261, width=2)
l361 := line.new(x1, y361, x2, y361, xloc=xloc.bar_index, extend=extend.none, color=c361, width=2)
l461 := line.new(x1, y461, x2, y461, xloc=xloc.bar_index, extend=extend.none, color=c461, width=2)
lf := linefill.new(l95, l105, color= show95_105 ? colBandFill : color.new(color.black, 100))
else
int t1 = f_abs_to_time(p3Abs)
int t2 = int(na)
if not na(t1)
t2 := t1 + feLenBars * tfms
l95 := line.new(t1, y95, t2, y95, xloc=xloc.bar_time, extend=extend.none, color=c95, width=3)
l105 := line.new(t1, y105, t2, y105, xloc=xloc.bar_time, extend=extend.none, color=c105, width=3)
l161 := line.new(t1, y161, t2, y161, xloc=xloc.bar_time, extend=extend.none, color=c161, width=2)
l261 := line.new(t1, y261, t2, y261, xloc=xloc.bar_time, extend=extend.none, color=c261, width=2)
l361 := line.new(t1, y361, t2, y361, xloc=xloc.bar_time, extend=extend.none, color=c361, width=2)
l461 := line.new(t1, y461, t2, y461, xloc=xloc.bar_time, extend=extend.none, color=c461, width=2)
lf := linefill.new(l95, l105, color= show95_105 ? colBandFill : color.new(color.black, 100))
array.push(FE_l95, l95)
array.push(FE_l105, l105)
array.push(FE_l161, l161)
array.push(FE_l261, l261)
array.push(FE_l361, l361)
array.push(FE_l461, l461)
array.push(FE_fill, lf)
array.push(FE_born, bar_index)
f_find_abs_by_time(t) =>
int bestAbs = na
if na(t)
na
else
int maxBack = math.min(5000, bar_index)
int bestDiff = 1000000000
for i = 0 to maxBack
int ti = time
int diff = ti > t ? (ti - t) : (t - ti)
if diff < bestDiff
bestDiff := diff
bestAbs := bar_index - i
bestAbs
//──────────────────────────────── P3 picker (แบบเดิม/คลาสสิก) ─────────────────────
f_pickP3_abs(sAbs, eAbs, isLong) =>
if na(sAbs) or na(eAbs)
else
int eInit = math.min(eAbs, bar_index)
int sInit = sAbs
int s = math.max(sInit, bar_index - 10000)
int e = eInit
if s > e
else
float levels = array.new_float()
int counts = array.new_int()
int firstI = array.new_int()
int maxRun = array.new_int()
float prevBin = na
int curRun = 0
float minLowGreen = 1e100
int minLowGreenI = na
float minLowRed = 1e100
int minLowRedI = na
float minLowAll = 1e100
int minLowAllI = na
float maxHighRed = -1e100
int maxHighRedI = na
float maxHighGreen = -1e100
int maxHighGreenI= na
float maxHighAll = -1e100
int maxHighAllI = na
for t = s to e
int tOff = bar_index - t
if tOff < 0 or tOff > 10000
continue
float bin = math.round(open / syminfo.mintick) * syminfo.mintick
int idx = array.indexof(levels, bin)
if idx == -1
array.push(levels, bin)
array.push(counts, 1)
array.push(firstI, t)
array.push(maxRun, 1)
curRun := 1
else
array.set(counts, idx, array.get(counts, idx) + 1)
if not na(prevBin) and bin == prevBin
curRun += 1
else
curRun := 1
int prevMax = array.get(maxRun, idx)
if curRun > prevMax
array.set(maxRun, idx, curRun)
prevBin := bin
// ... (ส่วนท้ายของ f_pickP3_abs เดิม)
int needCnt = 2
int best = -1, bestCnt = 0, bestRun = 0, bestFirst = 1000000000
int L = array.size(levels)
if L > 0
for m = 0 to L - 1
int c = array.get(counts, m)
if c >= needCnt
int r = array.get(maxRun, m)
int f = array.get(firstI, m)
if c > bestCnt or (c == bestCnt and (r > bestRun or (r == bestRun and f < bestFirst)))
best := m
bestCnt := c
bestRun := r
bestFirst := f
if best != -1
int pickAbs = array.get(firstI, best)
float pickPx = array.get(levels, best)
else
if isLong
// เลือกจาก logic เดิม (ย่อ)
float minLowGreen = 1e100
int minLowGreenI = na
float minLowRed = 1e100
int minLowRedI = na
float minLowAll = 1e100
int minLowAllI = na
for t2 = s to e
int toff2 = bar_index - t2
if toff2 < 0 or toff2 > 10000
continue
bool g = close > open
bool r = close < open
if g and low < minLowGreen
minLowGreen := low
minLowGreenI := t2
if r and low < minLowRed
minLowRed := low
minLowRedI := t2
if low < minLowAll
minLowAll := low
minLowAllI := t2
bool redIsGlobalMin = not na(minLowRedI) and (minLowRed <= minLowAll + 0.0)
if redIsGlobalMin
int offR = bar_index - minLowRedI
[close , minLowRedI]
else
int useAbs = na(minLowGreenI) ? minLowAllI : minLowGreenI
int offU = bar_index - useAbs
[open , useAbs]
else
float maxHighRed = -1e100
int maxHighRedI = na
float maxHighGreen = -1e100
int maxHighGreenI= na
float maxHighAll = -1e100
int maxHighAllI = na
for t3 = s to e
int toff3 = bar_index - t3
if toff3 < 0 or toff3 > 10000
continue
bool g2 = close > open
bool r2 = close < open
if r2 and high > maxHighRed
maxHighRed := high
maxHighRedI := t3
if g2 and high > maxHighGreen
maxHighGreen := high
maxHighGreenI:= t3
if high > maxHighAll
maxHighAll := high
maxHighAllI := t3
bool greenIsGlobalMax = not na(maxHighGreenI) and (maxHighGreen >= maxHighAll - 0.0)
if greenIsGlobalMax
int offG = bar_index - maxHighGreenI
[close , maxHighGreenI]
else
int useAbsS = na(maxHighRedI) ? maxHighAllI : maxHighRedI
int offS = bar_index - useAbsS
[open , useAbsS]
//──────────────────────────────── P1/P2/P3 (Auto; state) ────────────────
// LONG state vars
var int L_P1Abs = int(na)
var int L_P2Abs = int(na)
var int L_P3Abs = int(na)
var int L_winOpenAbs = int(na)
var float L_P1Open = na
var float L_P2Close = na
var float L_P3Px = na
var float L_P2_bodyTop = na
var float L_P2_bodyBot = na
// SHORT state vars
var int S_P1Abs = int(na)
var int S_P2Abs = int(na)
var int S_P3Abs = int(na)
var int S_winOpenAbs = int(na)
var float S_P1Open = na
var float S_P2Close = na
var float S_P3Px = na
var float S_P2_bodyTop = na
var float S_P2_bodyBot = na
// draw-set containers
var box L_SET_BOX = array.new_box()
var label L_SET_LBL = array.new_label()
var box S_SET_BOX = array.new_box()
var label S_SET_LBL = array.new_label()
// scanners
var bool L_seek = false
var bool L_confirmActive = false
var int L_runMaxAbs = int(na)
var float L_runMaxClose = na
var int L_candAbs = int(na)
var float L_candClose = na
var bool S_seek = false
var bool S_confirmActive = false
var int S_runMinAbs = int(na)
var float S_runMinClose = na
var int S_candAbs = int(na)
var float S_candClose = na
// LONG: seed/confirm P2 (UPDATED: ต้องทั้งแท่งอยู่เหนือ fiveUp_200)
if not L_seek and not L_confirmActive
float __btL = math.max(open, close)
float __bbL = math.min(open, close)
float __fiveL = fiveUp_200
bool startLongSeed = close > open and not na(__fiveL) and (__bbL >= __fiveL)
if startLongSeed
L_seek := true
L_runMaxAbs := bar_index
L_runMaxClose := close
if L_confirmActive
if close > L_candClose and close > open
L_seek := true
L_confirmActive := false
L_candAbs := int(na)
L_candClose := na
L_runMaxAbs := bar_index
L_runMaxClose := close
else if bar_index >= L_candAbs + rightWinBars
bool acceptL = true
// ตรวจซ้ำที่แท่งผู้สมัคร (ทั้งแท่งต้องอยู่เหนือ fiveUp_200)
int offCandL = bar_index - L_candAbs
float _btL = math.max(open , close )
float _bbL = math.min(open , close )
float _fiveL = fiveUp_200
bool bodyAbove5 = not na(_fiveL) and (_bbL >= _fiveL)
acceptL := acceptL and bodyAbove5
if not na(L_prevP2Abs)
int dBarsL = L_candAbs - L_prevP2Abs
if dBarsL <= p2NewWithinBars
acceptL := acceptL and (L_candClose > L_prevP2Close)
if not acceptL
L_seek := true
L_confirmActive := false
L_runMaxAbs := bar_index
L_runMaxClose := close
L_candAbs := int(na)
L_candClose := na
else
array.clear(L_SET_BOX)
array.clear(L_SET_LBL)
L_P2Abs := L_candAbs
resetReqAllL := false
resetReqP1L := false
resetReqP2L := false
resetReqP3L := false
int offP2 = bar_index - L_P2Abs
L_P2Close := close
L_P2_bodyTop := math.max(open , close )
L_P2_bodyBot := math.min(open , close )
L_prevP2Abs := L_P2Abs
L_prevP2Close := L_P2Close
= f_draw_mark_group(L_P2Abs, false, P2BoxColor, P2BoxFillTransp, BoxBorderTransp, showP2Label, "P2", true)
= f_enforce_and_set(L_P2Abs, bxP2, lbP2, L_lastP2Abs, L_lastP2Box, L_lastP2Lbl)
if keepNewP2L
L_lastP2Abs := _newAbsP2L
L_lastP2Box := _newBoxP2L
L_lastP2Lbl := _newLblP2L
f_del_if_exists(L_lastP3Box, L_lastP3Lbl)
L_lastP3Abs := int(na)
L_lastP3Box := na
L_lastP3Lbl := na
L_P3Abs := int(na)
L_P3Px := na
f_clear_all_fe()
L_winOpenAbs := L_P2Abs + 1
int bestAbs = int(na)
float bestDist = na
for k = 1 to 50
int a = L_P2Abs - k
if a < 0
break
int off = bar_index - a
if off < 0 or off > 5000
continue
if close <= open
continue
float ema5u85 = fiveUp_85
if na(ema5u85)
continue
float bt = math.max(open , close )
float bb = math.min(open , close )
float body = bt - bb
float fracAbove = body <= 0 ? 0.0 : math.max(0.0, bt - math.max(bb, ema5u85))/body
if fracAbove >= 0.25
float d = math.abs(mid200 - (bt+bb)/2.0)
if na(bestDist) or d < bestDist or (d == bestDist and (na(bestAbs) or a < bestAbs))
bestDist := d
bestAbs := a
if not na(bestAbs) and f_gap_ok_left(bestAbs, L_P2Abs)
int offb = bar_index - bestAbs
L_P1Open := open
L_P1Abs := bestAbs
= f_draw_mark_group(L_P1Abs, false, P1BoxColor, P1BoxFillTransp, BoxBorderTransp, showP1Label, "P1", true)
= f_enforce_and_set(L_P1Abs, bxP1, lbP1, L_lastP1Abs, L_lastP1Box, L_lastP1Lbl)
if keepNewP1L
L_lastP1Abs := _newAbsP1L
L_lastP1Box := _newBoxP1L
L_lastP1Lbl := _newLblP1L
L_seek := false
L_confirmActive := false
L_candAbs := int(na)
L_candClose := na
L_runMaxAbs := int(na)
L_runMaxClose := na
if L_seek and not L_confirmActive
if close > open
if close > nz(L_runMaxClose, -1e100)
L_runMaxClose := close
L_runMaxAbs := bar_index
else if close < nz(L_runMaxClose, 1e100)
L_candAbs := L_runMaxAbs
L_candClose := L_runMaxClose
L_seek := false
L_confirmActive := true
else if open < nz(L_runMaxClose, 1e100)
L_candAbs := L_runMaxAbs
L_candClose := L_runMaxClose
L_seek := false
L_confirmActive := true
// SHORT: seed/confirm P2 (UPDATED: ต้องทั้งแท่งอยู่ใต้ fiveDown_200)
if not S_seek and not S_confirmActive
float __btS = math.max(open, close)
float __bbS = math.min(open, close)
float __fiveS = fiveDown_200
bool startShortSeed = close < open and not na(__fiveS) and (__btS <= __fiveS)
if startShortSeed
S_seek := true
S_runMinAbs := bar_index
S_runMinClose := close
if S_confirmActive
if close < S_candClose and close < open
S_seek := true
S_confirmActive := false
S_candAbs := int(na)
S_candClose := na
S_runMinAbs := bar_index
S_runMinClose := close
else if bar_index >= S_candAbs + rightWinBars
bool acceptS = true
// ตรวจซ้ำที่แท่งผู้สมัคร (ทั้งแท่งต้องอยู่ใต้ fiveDown_200)
int offCandS = bar_index - S_candAbs
float _btS = math.max(open , close )
float _bbS = math.min(open , close )
float _fiveS = fiveDown_200
bool bodyBelow5 = not na(_fiveS) and (_btS <= _fiveS)
acceptS := acceptS and bodyBelow5
if not na(S_prevP2Abs)
int dBarsS = S_candAbs - S_prevP2Abs
if dBarsS <= p2NewWithinBars
acceptS := acceptS and (S_candClose < S_prevP2Close)
if not acceptS
S_seek := true
S_confirmActive := false
S_runMinAbs := bar_index
S_runMinClose := close
S_candAbs := int(na)
S_candClose := na
else
array.clear(S_SET_BOX)
array.clear(S_SET_LBL)
S_P2Abs := S_candAbs
resetReqAllS := false
resetReqP1S := false
resetReqP2S := false
resetReqP3S := false
int offP2s = bar_index - S_P2Abs
S_P2Close := close
S_P2_bodyTop := math.max(open , close )
S_P2_bodyBot := math.min(open , close )
S_prevP2Abs := S_P2Abs
S_prevP2Close := S_P2Close
= f_draw_mark_group(S_P2Abs, false, P2BoxColor, P2BoxFillTransp, BoxBorderTransp, showP2Label, "P2", false)
= f_enforce_and_set(S_P2Abs, bxP2s, lbP2s, S_lastP2Abs, S_lastP2Box, S_lastP2Lbl)
if keepNewP2S
S_lastP2Abs := _newAbsP2S
S_lastP2Box := _newBoxP2S
S_lastP2Lbl := _newLblP2S
f_del_if_exists(S_lastP3Box, S_lastP3Lbl)
S_lastP3Abs := int(na)
S_lastP3Box := na
S_lastP3Lbl := na
S_P3Abs := int(na)
S_P3Px := na
f_clear_all_fe()
S_winOpenAbs := S_P2Abs + 1
int bestAbsS = int(na)
float bestDistS = na
for k = 1 to 50
int a = S_P2Abs - k
if a < 0
break
int off = bar_index - a
if off < 0 or off > 5000
continue
if close >= open
continue
float ema5d85 = fiveDown_85
if na(ema5d85)
continue
float bt = math.max(open , close )
float bb = math.min(open , close )
float body = bt - bb
float fracBelow = body <= 0 ? 0.0 : math.max(0.0, math.min(bt, ema5d85) - bb)/body
if fracBelow >= 0.25
float d = math.abs(mid200 - (bt+bb)/2.0)
if na(bestDistS) or d < bestDistS or (d == bestDistS and (na(bestAbsS) or a < bestAbsS))
bestDistS := d
bestAbsS := a
if not na(bestAbsS) and f_gap_ok_left(bestAbsS, S_P2Abs)
int offb = bar_index - bestAbsS
S_P1Open := open
S_P1Abs := bestAbsS
= f_draw_mark_group(S_P1Abs, false, P1BoxColor, P1BoxFillTransp, BoxBorderTransp, showP1Label, "P1", false)
= f_enforce_and_set(S_P1Abs, bxP1s, lbP1s, S_lastP1Abs, S_lastP1Box, S_lastP1Lbl)
if keepNewP1S
S_lastP1Abs := _newAbsP1S
S_lastP1Box := _newBoxP1S
S_lastP1Lbl := _newLblP1S
S_seek := false
S_confirmActive := false
S_candAbs := int(na)
S_candClose := na
S_runMinAbs := int(na)
S_runMinClose := na
if S_seek and not S_confirmActive
if close < open
if close < nz(S_runMinClose, 1e100)
S_runMinClose := close
S_runMinAbs := bar_index
else if close > nz(S_runMinClose, -1e100)
S_candAbs := S_runMinAbs
S_candClose := S_runMinClose
S_seek := false
S_confirmActive := true
else if open > nz(S_runMinClose, -1e100)
S_candAbs := S_runMinAbs
S_candClose := S_runMinClose
S_seek := false
S_confirmActive := true
// ---------- LONG: close P3 window (classic picker) ----------
if not na(L_winOpenAbs)
int sAbs = L_winOpenAbs
int eAbs = bar_index
float rangeBody = L_P2_bodyTop - L_P2_bodyBot
float T33 = L_P2_bodyBot + rangeBody/3.0
float T75 = L_P2_bodyBot + rangeBody*0.75
int barsInWin = bar_index - L_winOpenAbs + 1
bool allowNormal = barsInWin >= 5 and close > open and close >= T33
bool allowEarly = barsInWin < 5 and close > open and close >= T75
if allowNormal or allowEarly
= f_pickP3_abs(sAbs, eAbs, true)
if not na(p3AbsL) and f_gap_ok_right(p3AbsL, L_P2Abs)
L_P3Abs := p3AbsL
L_P3Px := p3PxL_tmp
= f_draw_mark_group(L_P3Abs, false, P3BoxColor, P3BoxFillTransp, BoxBorderTransp, showP3Label, "P3", true)
= f_enforce_and_set(L_P3Abs, bxP3, lbP3, L_lastP3Abs, L_lastP3Box, L_lastP3Lbl)
if keepNewP3L
L_lastP3Abs := _newAbsP3L
L_lastP3Box := _newBoxP3L
L_lastP3Lbl := _newLblP3L
if showFE and not na(L_P1Open) and not na(L_P2Close)
float W = L_P2Close - L_P1Open
if W > 0
float y95 = f_rt(L_P3Px + 0.95 * W)
float y105 = f_rt(L_P3Px + 1.05 * W)
float y1618 = f_rt(L_P3Px + 1.618 * W)
float y2618 = f_rt(L_P3Px + 2.618 * W)
float y3618 = f_rt(L_P3Px + 3.618 * W)
float y4618 = f_rt(L_P3Px + 4.618 * W)
f_clear_all_fe()
f_add_fe_set(L_P3Abs, y95, y105, y1618, y2618, y3618, y4618)
L_winOpenAbs := int(na)
// ---------- SHORT: close P3 window (classic picker) ----------
if not na(S_winOpenAbs)
int sAbsS = S_winOpenAbs
int eAbsS = bar_index
float rangeBodyS = S_P2_bodyTop - S_P2_bodyBot
float T33d = S_P2_bodyTop - rangeBodyS/3.0
float T75d = S_P2_bodyTop - rangeBodyS*0.75
int barsInWinS = bar_index - S_winOpenAbs + 1
bool allowNormalS = barsInWinS >= 5 and close < open and close <= T33d
bool allowEarlyS = barsInWinS < 5 and close < open and close <= T75d
if allowNormalS or allowEarlyS
= f_pickP3_abs(sAbsS, eAbsS, false)
if not na(p3AbsS) and f_gap_ok_right(p3AbsS, S_P2Abs)
S_P3Abs := p3AbsS
S_P3Px := p3PxS_tmp
= f_draw_mark_group(S_P3Abs, false, P3BoxColor, P3BoxFillTransp, BoxBorderTransp, showP3Label, "P3", false)
= f_enforce_and_set(S_P3Abs, bxP3s, lbP3s, S_lastP3Abs, S_lastP3Box, S_lastP3Lbl)
if keepNewP3S
S_lastP3Abs := _newAbsP3S
S_lastP3Box := _newBoxP3S
S_lastP3Lbl := _newLblP3S
if showFE and not na(S_P1Open) and not na(S_P2Close)
float Ws = S_P2Close - S_P1Open
if Ws < 0
float y95s = f_rt(S_P3Px + 0.95 * Ws)
float y105s = f_rt(S_P3Px + 1.05 * Ws)
float y1618s = f_rt(S_P3Px + 1.618 * Ws)
float y2618s = f_rt(S_P3Px + 2.618 * Ws)
float y3618s = f_rt(S_P3Px + 3.618 * Ws)
float y4618s = f_rt(S_P3Px + 4.618 * Ws)
f_clear_all_fe()
f_add_fe_set(S_P3Abs, y95s, y105s, y1618s, y2618s, y3618s, y4618s)
S_winOpenAbs := int(na)
//──────────────────────────────── Manual Layer (+ Reset Latches) ─────────────────────
f_pick_abs_from_manual(_use, _pickMode, _time, _offset) =>
if not _use
na
else
_pickMode == PK_TIME ? f_find_abs_by_time(_time) : (bar_index + _offset)
f_pick_price_from_manual(_use, _abs, _pmode, _custom) =>
if not _use or na(_abs)
na
else
int off = bar_index - _abs
off < 0 or off > 5000 ? na : f_price_by_mode(off, _pmode, _custom)
useP1L_eff = useManP1L and not (resetReqAllL or resetReqP1L)
useP2L_eff = useManP2L and not (resetReqAllL or resetReqP2L)
useP3L_eff = useManP3L and not (resetReqAllL or resetReqP3L)
useP1S_eff = useManP1S and not (resetReqAllS or resetReqP1S)
useP2S_eff = useManP2S and not (resetReqAllS or resetReqP2S)
useP3S_eff = useManP3S and not (resetReqAllS or resetReqP3S)
// Effective ABS
int L_P1Abs_eff = useP1L_eff ? f_pick_abs_from_manual(useP1L_eff, pickP1L, manP1L_t, manP1L_of) : L_P1Abs
int L_P2Abs_eff = useP2L_eff ? f_pick_abs_from_manual(useP2L_eff, pickP2L, manP2L_t, manP2L_of) : L_P2Abs
int L_P3Abs_eff = useP3L_eff ? f_pick_abs_from_manual(useP3L_eff, pickP3L, manP3L_t, manP3L_of) : L_P3Abs
int S_P1Abs_eff = useP1S_eff ? f_pick_abs_from_manual(useP1S_eff, pickP1S, manP1S_t, manP1S_of) : S_P1Abs
int S_P2Abs_eff = useP2S_eff ? f_pick_abs_from_manual(useP2S_eff, pickP2S, manP2S_t, manP2S_of) : S_P2Abs
int S_P3Abs_eff = useP3S_eff ? f_pick_abs_from_manual(useP3S_eff, pickP3S, manP3S_t, manP3S_of) : S_P3Abs
// Effective Prices
float L_P1Open_eff = useP1L_eff ? f_pick_price_from_manual(useP1L_eff, L_P1Abs_eff, pmP1L, p1L_custom) : L_P1Open
float L_P2Close_eff = useP2L_eff ? f_pick_price_from_manual(useP2L_eff, L_P2Abs_eff, pmP2L, p2L_custom) : L_P2Close
float L_P3Px_eff = useP3L_eff ? f_pick_price_from_manual(useP3L_eff, L_P3Abs_eff, pmP3L, p3L_custom) : L_P3Px
float S_P1Open_eff = useP1S_eff ? f_pick_price_from_manual(useP1S_eff, S_P1Abs_eff, pmP1S, p1S_custom) : S_P1Open
float S_P2Close_eff = useP2S_eff ? f_pick_price_from_manual(useP2S_eff, S_P2Abs_eff, pmP2S, p2S_custom) : S_P2Close
float S_P3Px_eff = useP3S_eff ? f_pick_price_from_manual(useP3S_eff, S_P3Abs_eff, pmP3S, p3S_custom) : S_P3Px
// Redraw labels/boxes if manual in effect (apply de-dup too) — with GAP RULE
bool needRedrawL = useP1L_eff or useP2L_eff or useP3L_eff
bool needRedrawS = useP1S_eff or useP2S_eff or useP3S_eff
if needRedrawL
f_delete_boxes(L_SET_BOX)
f_delete_labels(L_SET_LBL)
if not na(L_P1Abs_eff) and not na(L_P2Abs_eff) and f_gap_ok_left(L_P1Abs_eff, L_P2Abs_eff) and showP1Label
= f_draw_mark_group(L_P1Abs_eff, false, P1BoxColor, P1BoxFillTransp, BoxBorderTransp, true, "P1", true)
= f_enforce_and_set(L_P1Abs_eff, bx1, lb1, L_lastP1Abs, L_lastP1Box, L_lastP1Lbl)
if keepP1L_m
L_lastP1Abs := nAbsP1L_m
L_lastP1Box := nBoxP1L_m
L_lastP1Lbl := nLblP1L_m
if not na(L_P2Abs_eff) and showP2Label
= f_draw_mark_group(L_P2Abs_eff, false, P2BoxColor, P2BoxFillTransp, BoxBorderTransp, true, "P2", true)
= f_enforce_and_set(L_P2Abs_eff, bx2, lb2, L_lastP2Abs, L_lastP2Box, L_lastP2Lbl)
if keepP2L_m
L_lastP2Abs := nAbsP2L_m
L_lastP2Box := nBoxP2L_m
L_lastP2Lbl := nLblP2L_m
if not na(L_P3Abs_eff) and not na(L_P2Abs_eff) and f_gap_ok_right(L_P3Abs_eff, L_P2Abs_eff) and showP3Label
= f_draw_mark_group(L_P3Abs_eff, false, P3BoxColor, P3BoxFillTransp, BoxBorderTransp, true, "P3", true)
= f_enforce_and_set(L_P3Abs_eff, bx3, lb3, L_lastP3Abs, L_lastP3Box, L_lastP3Lbl)
if keepP3L_m
L_lastP3Abs := nAbsP3L_m
L_lastP3Box := nBoxP3L_m
L_lastP3Lbl := nLblP3L_m
if needRedrawS
f_delete_boxes(S_SET_BOX)
f_delete_labels(S_SET_LBL)
if not na(S_P1Abs_eff) and not na(S_P2Abs_eff) and f_gap_ok_left(S_P1Abs_eff, S_P2Abs_eff) and showP1Label
= f_draw_mark_group(S_P1Abs_eff, false, P1BoxColor, P1BoxFillTransp, BoxBorderTransp, true, "P1", false)
= f_enforce_and_set(S_P1Abs_eff, bx1s, lb1s, S_lastP1Abs, S_lastP1Box, S_lastP1Lbl)
if keepP1S_m
S_lastP1Abs := nAbsP1S_m
S_lastP1Box := nBoxP1S_m
S_lastP1Lbl := nLblP1S_m
if not na(S_P2Abs_eff) and showP2Label
= f_draw_mark_group(S_P2Abs_eff, false, P2BoxColor, P2BoxFillTransp, BoxBorderTransp, true, "P2", false)
= f_enforce_and_set(S_P2Abs_eff, bx2s, lb2s, S_lastP2Abs, S_lastP2Box, S_lastP2Lbl)
if keepP2S_m
S_lastP2Abs := nAbsP2S_m
S_lastP2Box := nBoxP2S_m
S_lastP2Lbl := nLblP2S_m
if not na(S_P3Abs_eff) and not na(S_P2Abs_eff) and f_gap_ok_right(S_P3Abs_eff, S_P2Abs_eff) and showP3Label
= f_draw_mark_group(S_P3Abs_eff, false, P3BoxColor, P3BoxFillTransp, BoxBorderTransp, true, "P3", false)
= f_enforce_and_set(S_P3Abs_eff, bx3s, lb3s, S_lastP3Abs, S_lastP3Box, S_lastP3Lbl)
if keepP3S_m
S_lastP3Abs := nAbsP3S_m
S_lastP3Box := nBoxP3S_m
S_lastP3Lbl := nLblP3S_m
// FE from effective points (Manual precedence) — add GAP RULE
bool canFE_L = showFE and not na(L_P1Open_eff) and not na(L_P2Close_eff) and not na(L_P3Px_eff) and not na(L_P1Abs_eff) and not na(L_P2Abs_eff) and not na(L_P3Abs_eff) and f_gap_ok_left(L_P1Abs_eff, L_P2Abs_eff) and f_gap_ok_right(L_P3Abs_eff, L_P2Abs_eff)
bool canFE_S = showFE and not na(S_P1Open_eff) and not na(S_P2Close_eff) and not na(S_P3Px_eff) and not na(S_P1Abs_eff) and not na(S_P2Abs_eff) and not na(S_P3Abs_eff) and f_gap_ok_left(S_P1Abs_eff, S_P2Abs_eff) and f_gap_ok_right(S_P3Abs_eff, S_P2Abs_eff)
if canFE_L
float W = L_P2Close_eff - L_P1Open_eff
if W > 0
float y95 = f_rt(L_P3Px_eff + 0.95 * W)
float y105 = f_rt(L_P3Px_eff + 1.05 * W)
float y1618 = f_rt(L_P3Px_eff + 1.618 * W)
float y2618 = f_rt(L_P3Px_eff + 2.618 * W)
float y3618 = f_rt(L_P3Px_eff + 3.618 * W)
float y4618 = f_rt(L_P3Px_eff + 4.618 * W)
f_clear_all_fe()
f_add_fe_set(L_P3Abs_eff, y95, y105, y1618, y2618, y3618, y4618)
else if canFE_S
float Ws = S_P2Close_eff - S_P1Open_eff
if Ws < 0
float y95s = f_rt(S_P3Px_eff + 0.95 * Ws)
float y105s = f_rt(S_P3Px_eff + 1.05 * Ws)
float y1618s = f_rt(S_P3Px_eff + 1.618 * Ws)
float y2618s = f_rt(S_P3Px_eff + 2.618 * Ws)
float y3618s = f_rt(S_P3Px_eff + 3.618 * Ws)
float y4618s = f_rt(S_P3Px_eff + 4.618 * Ws)
f_clear_all_fe()
f_add_fe_set(S_P3Abs_eff, y95s, y105s, y1618s, y2618s, y3618s, y4618s)
// FE lifespan cleanup
int nBorn = array.size(FE_born)
if nBorn > 0
for k = 0 to nBorn - 1
int idx = nBorn - 1 - k
int born = array.get(FE_born, idx)
if bar_index - born > feLife
f_delete_fe_index(idx)
// Candle coloring
bool isP1_bar = (not na(L_P1Abs_eff) and bar_index == L_P1Abs_eff) or (not na(S_P1Abs_eff) and bar_index == S_P1Abs_eff)
bool isP2_bar = (not na(L_P2Abs_eff) and bar_index == L_P2Abs_eff) or (not na(S_P2Abs_eff) and bar_index == S_P2Abs_eff)
bool isP3_bar = (not na(L_P3Abs_eff) and bar_index == L_P3Abs_eff) or (not na(S_P3Abs_eff) and bar_index == S_P3Abs_eff)
color _candleCol = na
_candleCol := isP3_bar ? colP3Candle : (isP2_bar ? colP2Candle : (isP1_bar ? colP1Candle : na))
barcolor(recolorBars ? _candleCol : na)
// Reserve style slot
plot(showFE ? na : na, title="fe-slot")
//──────────────────────────────── di (DSI; masked) ───────────────────────────
float dsi_atr = ta.atr(14)
float dsi_highestBody = open > close ? open : close
float dsi_lowestBody = open > close ? close : open
var float dsi_res1 = na
var float dsi_res2 = na
var float dsi_sup1 = na
var float dsi_sup2 = na
var bool dsi_lookForNewResistance = true
var bool dsi_lookForNewSupport = true
var float dsi_prevRes1 = na
var float dsi_prevRes2 = na
var float dsi_prevSup1 = na
var float dsi_prevSup2 = na
var float dsi_atrSaved = na
var float dsi_potR1 = na
var float dsi_potR2 = na
var float dsi_potS1 = na
var float dsi_potS2 = na
if high == ta.highest(high, lookback) and high < high and dsi_lookForNewResistance
float r1 = high
float hb2 = (open > close ? open : close )
float hb1 = (open > close ? open : close )
float hb0 = (open > close ? open : close)
float r2 = hb2 > hb1 ? hb2 : (hb0 > hb1 ? hb0 : hb1)
if (r1 - r2) / dsi_atr <= maxZoneSize
dsi_lookForNewResistance := false
dsi_potR1 := r1
dsi_potR2 := r2
dsi_atrSaved := dsi_atr
if low == ta.lowest(low, lookback) and low > low and dsi_lookForNewSupport
float s1 = low
float lb2 = (open > close ? close : open )
float lb1 = (open > close ? close : open )
float lb0 = (open > close ? close : open)
float s2 = lb2 < lb1 ? lb2 : (lb0 < lb1 ? lb0 : lb1)
if (s2 - s1) / dsi_atr <= maxZoneSize
dsi_lookForNewSupport := false
dsi_potS1 := s1
dsi_potS2 := s2
dsi_atrSaved := dsi_atr
if close > dsi_potR1 and barstate.isconfirmed
dsi_potR1 := na
dsi_potR2 := na
if close < dsi_potS1 and barstate.isconfirmed
dsi_potS1 := na
dsi_potS2 := na
if not na(dsi_potR1) and dsi_potR1 - low >= (nz(dsi_atrSaved, dsi_atr) * atrMovement)
dsi_prevRes1 := na(dsi_prevRes1) ? dsi_potR1 : dsi_prevRes1
dsi_prevRes2 := na(dsi_prevRes2) ? dsi_potR2 : dsi_prevRes2
dsi_res1 := dsi_potR1
dsi_res2 := dsi_potR2
dsi_potR1 := na
dsi_potR2 := na
if not na(dsi_potS1) and high - dsi_potS1 >= (nz(dsi_atrSaved, dsi_atr) * atrMovement)
dsi_prevSup1 := na(dsi_prevSup1) ? dsi_potS1 : dsi_prevSup1
dsi_prevSup2 := na(dsi_prevSup2) ? dsi_potS2 : dsi_prevSup2
dsi_sup1 := dsi_potS1
dsi_sup2 := dsi_potS2
dsi_potS1 := na
dsi_potS2 := na
var int dsi_supCount = 0
var int dsi_resCount = 0
if close >= dsi_res1 and barstate.isconfirmed
dsi_lookForNewResistance := true
dsi_lookForNewSupport := true
dsi_resCount += 1
if close <= dsi_sup1 and barstate.isconfirmed
dsi_lookForNewSupport := true
dsi_lookForNewResistance := true
dsi_supCount += 1
if (close > dsi_res1 and na(dsi_prevRes1) and barstate.isconfirmed) or na(dsi_prevRes1) or dsi_resCount >= newStructureReset
dsi_prevRes1 := dsi_res1
dsi_prevRes2 := dsi_res2
dsi_resCount := 0
if (close < dsi_sup1 and na(dsi_prevSup1) and barstate.isconfirmed) or na(dsi_prevSup1) or dsi_supCount >= newStructureReset
dsi_prevSup1 := dsi_sup1
dsi_prevSup2 := dsi_sup2
dsi_supCount := 0
if close < dsi_prevRes2 and barstate.isconfirmed
dsi_prevRes1 := na
dsi_prevRes2 := na
if close > dsi_prevSup2 and barstate.isconfirmed
dsi_prevSup1 := na
dsi_prevSup2 := na
dsi_r1plot = plot(showDSI and (dsi_res1 == dsi_res1 ) ? dsi_res1 : na, color=close >= dsi_res1 ? dsiBullColor : dsiBearColor, style=plot.style_linebr, title="di R1")
dsi_r2plot = plot(showDSI and (dsi_res1 == dsi_res1 ) ? dsi_res2 : na, color=close >= dsi_res1 ? dsiBullColor : dsiBearColor, style=plot.style_linebr, title="di R2")
fill(dsi_r1plot, dsi_r2plot, color=showDSI ? (close > dsi_res1 ? dsiBullColor : color.new(dsiBearColor, 50)) : color.new(color.black, 100), title="di Resistance Zone")
dsi_s1plot = plot(showDSI and (dsi_sup1 == dsi_sup1 ) ? dsi_sup1 : na, color=close < dsi_sup1 ? dsiBearColor : dsiBullColor, style=plot.style_linebr, title="di S1")
dsi_s2plot = plot(showDSI and (dsi_sup1 == dsi_sup1 ) ? dsi_sup2 : na, color=close < dsi_sup1 ? dsiBearColor : dsiBullColor, style=plot.style_linebr, title="di S2")
fill(dsi_s1plot, dsi_s2plot, color=showDSI ? (close < dsi_sup1 ? dsiBearColor : color.new(dsiBullColor, 50)) : color.new(color.black, 100), title="di Support Zone")
dsi_ps1plot = plot(showDSI and drawPreviousStructure and (dsi_prevSup1 == dsi_prevSup1 ) and (dsi_prevSup1 != dsi_sup1) ? dsi_prevSup1 : na, color=dsiBearColor, style=plot.style_linebr, title="di PS1")
dsi_ps2plot = plot(showDSI and drawPreviousStructure and (dsi_prevSup1 == dsi_prevSup1 ) and (dsi_prevSup1 != dsi_sup1) ? dsi_prevSup2 : na, color=dsiBearColor, style=plot.style_linebr, title="di PS2")
fill(dsi_ps1plot, dsi_ps2plot, color=showDSI and drawPreviousStructure ? color.new(dsiBearColor, 10) : color.new(color.black, 100), title="di Previous Support Zone")
dsi_pr1plot = plot(showDSI and drawPreviousStructure and (dsi_prevRes1 == dsi_prevRes1 ) and (dsi_prevRes1 != dsi_res1) ? dsi_prevRes1 : na, color=dsiBullColor, style=plot.style_linebr, title="di PR1")
dsi_pr2plot = plot(showDSI and drawPreviousStructure and (dsi_prevRes1 == dsi_prevRes1 ) and (dsi_prevRes1 != dsi_res1) ? dsi_prevRes2 : na, color=dsiBullColor, style=plot.style_linebr, title="di Previous Resistance Zone")
//────────────────────────── Elliptic Bands (masked, locked) ──────────────────────────
groupEllipse = "es bands"
EB_show = input.bool(true, "show es bands", group=groupEllipse)
EB_midColor = input.color(color.rgb(229,236,241), "mid color", group=groupEllipse)
EB_upColor = input.color(color.green, "upper color", group=groupEllipse)
EB_dnColor = input.color(color.red, "lower color", group=groupEllipse)
EB_fillTransp = input.int(80, "band transparency (0–100)", minval=0, maxval=100, group=groupEllipse)
EB_showFill = input.bool(false, "fill es cloud", group=groupEllipse)
EB_showSignals = input.bool(true, "show es signals", group=groupEllipse)
EB_buyColor = input.color(color.green, "buy signal color", group=groupEllipse)
EB_sellColor = input.color(color.red, "sell signal color", group=groupEllipse)
// locked params
const int EB_MA_LEN = 50
const int EB_PERIOD = 50
const float EB_MULTI = 2.0
float EB_central_ma = ta.sma(close, EB_MA_LEN)
float EB_b = ta.stdev(close, EB_MA_LEN) * EB_MULTI
int EB_cycle_pos = bar_index % EB_PERIOD
float EB_x = 2.0 * (EB_cycle_pos / EB_PERIOD) - 1.0
float EB_offset = EB_b * math.sqrt(math.max(0.0, 1.0 - EB_x * EB_x))
float EB_band_upper = EB_central_ma + EB_offset
float EB_band_lower = EB_central_ma - EB_offset
// plot lines (upper/lower/mid)
EB_p_mid = plot(EB_show ? EB_central_ma : na, title="es mid", color=EB_midColor, linewidth=1)
EB_p_up = plot(EB_show ? EB_band_upper : na, title="es upper", color=EB_upColor)
EB_p_dn = plot(EB_show ? EB_band_lower : na, title="es lower", color=EB_dnColor)
// fill only if EB_showFill = true
EB_fillColor = (EB_show and EB_showFill) ? color.new(color.gray, EB_fillTransp) : color.new(color.gray, 100)
fill(EB_p_up, EB_p_dn, color=EB_fillColor, title="es cloud")
// signals
bool EB_buy = EB_show and close < nz(EB_band_lower ) and close >= nz(EB_band_lower) and close <= nz(EB_band_upper) and barstate.isconfirmed
bool EB_sell = EB_show and close > nz(EB_band_upper ) and close >= nz(EB_band_lower) and close <= nz(EB_band_upper) and barstate.isconfirmed
plotshape(EB_showSignals and EB_buy, title="es buy", location=location.belowbar, color=EB_buyColor, style=shape.triangleup, size=size.tiny)
plotshape(EB_showSignals and EB_sell, title="es sell", location=location.abovebar, color=EB_sellColor, style=shape.triangledown, size=size.tiny)
// Wave Labels (1–5) — minimal module for tp11ofc1 (Pine v6) — labels only
//──────────────────────────────────────────────────────────────────────────────
groupEW = "Wave labels (Elliott)"
srcHiSel = input.string("high", "High source", options= , group=groupEW)
srcLoSel = input.string("low", "Low source", options= , group=groupEW)
ew_hi = srcHiSel == "high" ? high : srcHiSel == "close" ? close : math.max(open, close)
ew_lo = srcLoSel == "low" ? low : srcLoSel == "close" ? close : math.min(open, close)
ewShowS1 = input.bool(true, "Show wave S", group=groupEW, inline="s1")
ewLen1 = input.int(4, "len", minval=1, group=groupEW, inline="s1")
ewCol1 = input.color(color.new(color.red,0), "", group=groupEW, inline="s1")
ewShowS2 = input.bool(true, "Show wave M", group=groupEW, inline="s2")
ewLen2 = input.int(8, "len", minval=1, group=groupEW, inline="s2")
ewCol2 = input.color(color.new(#0d86e9, 0), "", group=groupEW, inline="s2")
ewShowS3 = input.bool(true, "Show wave L", group=groupEW, inline="s3")
ewLen3 = input.int(16, "len", minval=1, group=groupEW, inline="s3")
ewCol3 = input.color(color.new(#470303, 0),"", group=groupEW, inline="s3")
ewSizeStr = input.string("small","Label size", options= , group=groupEW)
ew_lsize(s) => s=="tiny"?size.tiny:s=="normal"?size.normal:s=="large"?size.large:size.small
type _ZZ
int d
int x
float y
newZZ() => _ZZ.new(array.new_int(), array.new_int(), array.new_float())
f_push_pivot(_aZZ, _dir, _x1, _y1, _x2, _y2) =>
_aZZ.d.unshift(_dir)
_aZZ.x.unshift(_x2)
_aZZ.y.unshift(_y2)
if array.size(_aZZ.d) > 12
_ = array.pop(_aZZ.d)
_ = array.pop(_aZZ.x)
_ = array.pop(_aZZ.y)
var label EW_LABELS = array.new_label()
f_add_label(_x, _y, _txt, _col, _up) =>
label lb = label.new(_x, _y, text=_txt, style=_up?label.style_label_down:label.style_label_up, textcolor=_col, color=color.new(color.black, 100), size=ew_lsize(ewSizeStr), xloc=xloc.bar_index)
array.push(EW_LABELS, lb)
if array.size(EW_LABELS) > 500
label.delete(array.get(EW_LABELS, 0))
array.remove(EW_LABELS, 0)
f_check_motive_bull(_1y,_2y,_3y,_4y,_5y,_6y) =>
_W5 = _6y - _5y
_W3 = _4y - _3y
_W1 = _2y - _1y
_min = math.min(_W1,_W3,_W5)
(_W3 != _min) and (_6y > _4y) and (_3y > _1y) and (_5y > _2y)
f_check_motive_bear(_1y,_2y,_3y,_4y,_5y,_6y) =>
_W5 = _5y - _6y
_W3 = _3y - _4y
_W1 = _1y - _2y
_min = math.min(_W1,_W3,_W5)
(_W3 != _min) and (_4y > _6y) and (_1y > _3y) and (_2y > _5y)
f_wave_labels(_enabled, _len, _col, _rowSep) =>
if _enabled
var _ZZ zz = newZZ()
if barstate.isfirst
for _=0 to 10
array.unshift(zz.d, 0)
array.unshift(zz.x, 0)
array.unshift(zz.y, 0)
x2 = bar_index - 1
ph = ta.pivothigh(ew_hi, _len, 1)
pl = ta.pivotlow (ew_lo, _len, 1)
if not na(ph)
dir = array.get(zz.d, 0)
x1 = array.get(zz.x, 0)
y1 = array.get(zz.y, 0)
y2h = nz(ew_hi )
if dir < 1
f_push_pivot(zz, 1, x1, y1, x2, y2h)
else if ph > y1
array.set(zz.x, 0, x2)
array.set(zz.y, 0, y2h)
_6x = x2, _6y = y2h
_5x = array.get(zz.x,1), _5y = array.get(zz.y,1)
_4x = array.get(zz.x
Quantel Swing ProQuantel Swing Pro is a precision tool designed for traders who want structured swing trade setups with clear rules. The indicator automatically provides:
Entry Signals – optimized swing trade triggers.
Stop Loss (SL) Levels – risk management boundaries based on recent structure.
Take Profit (TP) Targets – dynamic profit zones calculated using volatility and swing ranges.
💡 How to Use:
Ideal for swing trades on 4H, Daily, or Weekly charts (works across all timeframes).
Signals provide a full trade idea: entry, stop, and take profit levels.
Best used with trend confirmation tools (moving averages, higher timeframe bias, or liquidity sweeps).
✅ Features:
Complete trade framework in one tool.
Clean, easy-to-read chart signals.
Adjustable settings to fit your strategy and risk profile.
⚠️ Disclaimer: This tool is for educational purposes only. Not financial advice. Use at your own risk and always confirm signals with your personal trading plan.
Session Liquidity & Sweep DetectorThis indicator automatically detects and marks key liquidity sweep events on your chart:
LLS (Lower Liquidity Sweep): Price sweeps below prior lows to grab liquidity.
LHS (Lower High Sweep): Price sweeps above a minor high before rejecting.
ALS (Above Liquidity Sweep): Price sweeps above a key high, often signaling liquidity collection.
AHS (Above High Sweep): Price takes out a previous swing high, indicating possible trap or breakout.
How to Use:
Use signals as confluence with your trading system, not as stand-alone buy/sell triggers.
LLS/ALS can mark areas where liquidity is grabbed before reversal.
LHS/AHS can help identify false breakouts and stop hunts around key levels.
Combine with FVGs, BOS/CHOCH, or PO3 models for maximum effectiveness.
Features:
Clean on-chart signals for all 4 sweep types.
Works on all timeframes and symbols.
Helps traders spot liquidity hunts & manipulation points.
Disclaimer: This tool is for educational purposes only. Not financial advice. Always combine with your own analysis and risk management.
XAUUSD/SPX Slope with MACDThe XAUUSD/SPX Slope with MACD Indicator tracks the slope of the XAUUSD (Gold) to SPX (S&P 500) ratio using linear regression over a customizable lookback period (default 20 bars), plotted as a blue line to show Gold’s relative performance against stocks. A MACD overlay (fast: 12, slow: 26, signal: 9, scaled by 5) is applied to the slope, with a green MACD line, red signal line, and green/red histogram to highlight momentum. A positive slope indicates Gold outperforming SPX, while MACD trends provide additional context. A zero line and background coloring (green for positive slope, red for negative) aid interpretation. Ensure XAUUSD and SPX symbols are supported by your platform.
Usage Notes:
Interpretation:
Slope (Blue): Positive values indicate Gold outperforming SPX; negative values show SPX outperforming.
MACD Components: The green MACD line, red signal line, and histogram (green for positive, red for negative) reflect momentum in the slope. Crossovers or histogram shifts can be analyzed manually for potential trend changes.
Customization: Adjust lookback, macd_fast, macd_slow, or macd_signal to tune sensitivity. The MACD scale is fixed at 5 for clarity.
Symbol Check: Verify "XAUUSD" and "SPX" match your platform’s tickers (e.g., "GOLD" or "SP500").
3X Sniper BotThe 3X Sniper Bot is built for traders who demand clarity, precision, and confidence in their decision-making. This tool isn’t just another crossover script—it’s a full multi-confirmation system that helps you spot momentum shifts, identify high-probability entries, and filter out the noise.
🔥 Why traders love it:
Triple confirmation engine: Only fires when multiple conditions align, reducing false signals.
Strong vs. Regular vs. Possible setups: Get nuanced alerts that distinguish between high-conviction moves and early opportunities.
Both Buy & Sell coverage: Stay prepared in any market environment.
Smart flexibility: Works across strict or sequenced signal modes, giving you control over how conservative or aggressive you want to trade.
Visual clarity: Clean chart markers and optional regime shading keep your screen easy to read at a glance.
Alert-ready: Set and forget—never miss a move with real-time TradingView alerts.
This indicator was designed to make complex multi-factor analysis simple, giving traders a clear visual edge without clutter or guesswork. Whether you scalp intraday or swing multi-day, the 3X Sniper Bot adapts to your style.
HD_DİNAMİK SEMBOL-SİNYAL TABLO (STrend + EMA(25/99) – v6.2HD_Dynamic Symbol–Signal Table (Short/Mid/Long) — SuperTrend + EMA(25/99) — v6.2
TL;DR
Invite-only indicator that builds a multi-symbol live signal table combining SuperTrend direction with EMA 25/99 state, across three timeframe groups: Short (5/15/30), Mid (45/60/120), Long (180/240/D).
Top 2 rows (e.g., BTC, ETH) always show the full 3×(ST, EMA) matrix; the remaining rows show the active group to stay lightweight. The table colors & texts are highly configurable, and the indicator emits clean alert messages you can route to webhooks (e.g., your bot).
1) What it does
Signal logic (per symbol & timeframe):
SuperTrend direction + EMA 25 vs 99 comparison.
Combination map:
ST=LONG & EMA=LONG → "LONG YAP"
ST=SHORT & EMA=SHORT → "SHORT YAP"
ST=SHORT & EMA=LONG → "SHORT/LONG YAP" (mixed)
ST=LONG & EMA=SHORT → "LONG/SHORT YAP" (mixed)
Timeframe groups
Short: 5/15/30
Mid: 45/60/120
Long: 180/240/D
Auto mode infers the group from the chart TF; Manual mode lets you pin a group.
Pinned priority rows: Row #1 and #2 (default BTC/ETH) always display all three TFs (ST & EMA pairs).
Dynamic list (rows 3–30): Shows only the active group for each symbol to stay fast and readable.
Implementation note: in this build the ST “up”/“down” plotting uses the SuperTrend dir sign convention where dir < 0 is rendered as Uptrend and dir > 0 as Downtrend in visuals. The table/alerts already normalize this into LONG/SHORT text.
2) Table, styling & filters
Placement & fonts: position, title/group/header/body font sizes.
Colors: per-cell/background for header rows, LONG/SHORT states, and distinct brand colors per symbol row (BTC=blue, ETH=amber, majors=greens, mid-caps=oranges, high-risk=reds, new/hyped=purple range).
Symbol column text: “Symbol only”, “Short+Symbol”, or “Short only”.
Filter: Show All / LONG YAP / SHORT YAP / SHORT/LONG YAP / LONG/SHORT YAP. (Pinned BTC/ETH still visible.)
3) Alerts & webhook messages
Per-row alerts: When the active TF for a row resolves on bar close, the indicator sends:
|symbol=|tf=|signal=
Example: HD_ST_EMA|symbol=BINANCE:BTCUSDT|tf=15|signal=LONG YAP
Configure the alert to Once per bar close and set a webhook URL if you want to forward to an execution bot.
Ready-made alertconditions (Robot block):
Select a single alarmSymbol and get four conditions: LONG YAP, SHORT YAP, SHORT/LONG YAP, LONG/SHORT YAP.
Chart-symbol conditions: Extra alertconditions for EMA LONG/SHORT and ST LONG/SHORT on the current chart symbol, if you also want single-symbol triggers.
4) Drawing package (optional)
SuperTrend line with Up/Down segments and trend-flip labels.
EMA 25/99 lines and cross labels.
Main mixed-state labels for the chart symbol can be toggled (LONG/SHORT & mixed cases).
5) Symbols & safety
Priority inputs (#1–2) for BTC/ETH; inputs #3–30 for your list (supports formats like BINANCE:BTCUSDT or BTCUSDT.P).
A basic format validator ignores obviously malformed tickers to avoid request errors.
request.security() powers all multi-TF/multi-symbol reads.
6) How to use
Add indicator to the chart.
Choose Auto (group follows chart TF) or pick Short/Mid/Long manually.
Fill your symbol list (rows 3–30). BTC & ETH are pinned at the top.
Set filter (or keep “All”).
(Optional) Adjust fonts/colors and the “Symbol column” text mode.
Turn Alert on; set alertPrefix if you need a specific route tag.
Create an alert on the indicator, Once per bar close, and (optionally) add a webhook URL.
7) Notes & limits
This is an indicator (no orders are placed). Use the alerts to trigger your own automation.
Designed for crypto symbols; works on other markets if your vendor supports the tickers/timeframes.
Table resizes dynamically to your active list; heavy watchlists may still be constrained by platform limits.
8) Disclaimer
Educational use only. Not financial advice. Past performance does not guarantee future results.
Changelog
v6.2 — Auto/Manual TF-grouping, pinned BTC/ETH tri-TF view, robust alert text format, color-coded priorities, safer symbol validation, ST/EMA flip labels, dynamic table sizing.
Türkçe Özet
Ne yapar?
Birden fazla sembol için SuperTrend + EMA(25/99) durumunu üç periyot grubunda (Kısa 5/15/30 – Orta 45/60/120 – Uzun 180/240/Günlük) tek tabloda gösterir.
BTC/ETH ilk iki satırda her zaman 3×(ST, EMA) birlikte görünür; diğer satırlar aktif gruba göre (performans için) tek grup gösterir.
Sinyal mantığı
İkisi de LONG → LONG YAP
İkisi de SHORT → SHORT YAP
Karışık → SHORT/LONG YAP veya LONG/SHORT YAP (ST/EMA’ya göre)
Alarm & Webhook
Satır bazlı alarm metni:
HD_ST_EMA|symbol=...|tf=...|signal=... (bar kapanışında).
“Robot” bölümünde tek bir sembol için 4 ayrı alertcondition hazır.
Grafikteki sembol için ayrıca EMA LONG/SHORT ve ST LONG/SHORT koşulları da var.
Kullanım
Otomatik/Elle grup seç;
Listeyi doldur (3–30);
Filtre/renk/yazı ayarla;
Alarmı aç ve Once per bar close ile kur; gerekiyorsa webhook URL ekle.
Not
Gösterge emir vermez; sinyalleri kendi köprüne/botuna yönlendirirsin. Yatırım tavsiyesi değildir.
SVX (Sentiment Velocity Index) EMA & Slope StructureThe SVX Momentum Framework is designed as a momentum and slope visualization tool. Designed to identify momentum shifts and pre-move conditions within price action.
What it draws:
- Plots five EMAs (8, 20, 40, 100, 200) To visualize short/medium trend structure. You can pick which ones to see.
- Calculates an EMA-based slope (rate of change) from actual closing-price movement and colors a neutral/positive/negative background for context. This is not ATR or Supertrend.
- Shows optional triangle context markers on bars that meet wick/body conditions that often precede momentum transitions (off by default / user-controlled).
- Shows Reference close (optional): Use when you need to verify price relative to standard closes for easier zone and level marking.
How the components work together:
- The EMA stack provides directional alignment (compression/expansion and relative order of 8/20/40/100/200).
- The slope quantifies whether recent movement is neutral, building (Green), or fading (Red); the background simply reflects that state.
- The triangle context markers flag a bar-shape condition (wick/body relationship) that can precede changes in behavior.
- The reference close is a visual aid for clarity when users compare candle closes and trading zones or levels .
How to read it:
- Structure: Look for EMA ordering (at least 8/20/100 recommended) and spacing to understand the underlying bias and compression/expansion.
- Slope state: Neutral (no bias, white), positive (building, green), or negative (fading, red). Use it as context, not as entries/exits.
- Context markers (optional): Treat them as visual highlights.
- Reference close (optional): Use when you need to verify price relative to candle close for easier zone and level marking.
How to use it (general guidance):
- Read structure first (EMA order/spread), then consider the slope state to understand whether conditions are neutral or possibly momentum-driven in the indicated direction.
- Combine with your own entry rules and/or engulfing candle patterns for timing, risk, and apply your preferred management.
What’s original here:
- The slope visualization is derived from actual closing-price movement, not Supertrend or ATR overlays.
- The wick/body context markers focus on bars that often precede transitions, presented as optional visuals.
- The reference close overlay is included purely to aid interpretation when comparing views to the native close and for more clear zone and level marking.
Access & intent:
- Educational visualization of structure and slope, providing a framework traders can build upon.
- The author does not provide financial advice. Use at your own discretion.
Disclaimer
This script is provided for educational and informational purposes only. It does not constitute financial advice, investment recommendations, or a solicitation to trade. Past performance is not indicative of future results. The author assumes no responsibility for losses incurred from the use of this tool. TradingView, Inc. has no liability related to this script or its use.
MatrixScalper Tablo + 3 Bant Osilatör
MatrixScalper “Table + 3-Band Oscillator” is a lightweight, multi-timeframe trend-momentum filter that stacks three histograms (TF1/TF2/TF3—default 5m/15m/1h) and a compact table showing EMA trend, Supertrend, RSI and MACD direction for each timeframe. Green bars/✓ mean bullish alignment, red bars/✗ bearish; mixed or gray implies neutrality. Use it to trade with the higher-timeframe bias (e.g., look for longs when 15m & 60m are bullish and the 5m band flips back to green after a pullback). It’s a filter—not a standalone signal—so combine with price action/S&R/volume; optional alerts can be added for “all-bull” or “all-bear” alignment.
Breakout Paint Bars (IBS + Micro Channels)Breakout Paint Bars (IBS + Micro Channels)
This indicator highlights breakout candles using the Internal Bar Strength (IBS) and adds advanced filtering with suppression logic and optional micro channel detection.
📌 Features
IBS Breakout Detection
Bullish bars are painted when IBS ≥ user-defined threshold (default 69%) and the candle breaks above the previous candle’s high and close.
Bearish bars are painted when IBS ≤ user-defined threshold (default 31%) and the candle breaks below the previous candle’s low and close.
Suppression Logic
After a strong bullish bar, bearish IBS signals are suppressed until price closes below the bullish bar’s low.
After a strong bearish bar, bullish IBS signals are suppressed until price closes above the bearish bar’s high.
This reduces false signals and avoids premature coloring inside consolidation.
Micro Channel Detection (Optional)
A bull micro channel is 3+ consecutive bullish bars without a pullback (each low ≥ prior low). These are shaded in a darker cyan.
A bear micro channel is 3+ consecutive bearish bars without a pullback (each high ≤ prior high). These are shaded in a darker red.
You can enable/disable this with a checkbox in settings.
Customizable Colors & Thresholds
Adjust bullish/bearish IBS thresholds.
Change bullish/bearish colors for personalization.
🎯 Usage
Helps identify valid breakout bars while filtering out noise.
Suppression ensures breakout signals are only shown after key levels are taken out.
Micro channel coloring highlights strong trending phases without pullbacks.
⚠️ Notes
Works on all markets (stocks, forex, crypto, futures).
Designed for discretionary traders who want to spot momentum-driven breakouts and trend strength.
Deadband Hysteresis Supertrend [BackQuant]Deadband Hysteresis Supertrend
A two-stage trend tool that first filters price with a deadband baseline, then runs a Supertrend around that baseline with optional flip hysteresis and ATR-based adverse exits.
What this is
A hybrid of two ideas:
Deadband Hysteresis Baseline that only advances when price pulls far enough from the baseline to matter. This suppresses micro noise and gives you a stable centerline.
Supertrend bands wrapped around that baseline instead of raw price. Flips are further gated by an extra margin so side changes are more deliberate.
The goal is fewer whipsaws in chop and clearer regime identification during trends.
How it works (high level)
Deadband step — compute a per-bar “deadband” size from one of four modes: ATR, Percent of price, Ticks, or Points. If price deviates from the baseline by more than this amount, move the baseline forward by a fraction of the excess. If not, hold the line.
Centered Supertrend — build upper and lower bands around the baseline using ATR and a user factor. Track the usual trailing logic that tightens a band while price moves in its favor.
Flip hysteresis — require price to exceed the active band by an extra flip offset × ATR before switching sides. This adds stickiness at the boundary.
Adverse exit — once a side is taken, trigger an exit if price moves against the entry by K × ATR .
If you would like to check out the filter by itself:
What it plots
DBHF baseline (optional) as a smooth centerline.
DBHF Supertrend as the active trailing band.
Candle coloring by trend side for quick read.
Signal markers 𝕃 and 𝕊 at flips plus ✖ on adverse exits.
Inputs that matter
Price Source — series being filtered. Close is typical. HL2 or HLC3 can be steadier.
Deadband mode — ATR, Percent, Ticks, or Points. This defines the “it’s big enough to matter” zone.
ATR Length / Mult (DBHF) — only used when mode = ATR. Larger values widen the do-nothing zone.
Percent / Ticks / Points — alternatives to ATR; pick what fits your market’s convention.
Enter Mult — scales the deadband you must clear before the baseline moves. Increase to filter more noise.
Response — fraction of the excess applied to baseline movement. Higher responds faster; lower is smoother.
Supertrend ATR Period & Factor — traditional band size controls; higher factor widens and flips less often.
Flip Offset ATR — extra ATR buffer required to flip. Useful in choppy regimes.
Adverse Stop K·ATR — per-trade danger brake that forces an exit if price moves K×ATR against entry.
UI — toggle baseline, supertrend, signals, and bar painting; choose long and short colors.
How to read it
Green regime — candles painted long and the Supertrend running below price. Pullbacks toward the baseline that fail to breach the opposite band often resume higher.
Red regime — candles painted short and the Supertrend running above price. Rallies that cannot reclaim the band may roll over.
Frequent side swaps — reduce sensitivity by increasing Enter Mult, using ATR mode, raising the Supertrend factor, or adding Flip Offset ATR.
Use cases
Bias filter — allow entries only in the direction of the current side. Use your preferred triggers inside that bias.
Trailing logic — treat the active band as a dynamic stop. If the side flips or an adverse K·ATR exit prints, reduce or close exposure.
Regime map — on higher timeframes, the combination baseline + band produces a clean up vs down template for allocation decisions.
Tuning guidance
Fast markets — ATR deadband, modest Enter Mult (0.8–1.2), response 0.2–0.35, Supertrend factor 1.7–2.2, small Flip Offset (0.2–0.5 ATR).
Choppy ranges — widen deadband or raise Enter Mult, lower response, and add more Flip Offset so flips require stronger evidence.
Slow trends — longer ATR periods and higher Supertrend factor to keep you on side longer; use a conservative adverse K.
Included alerts
DBHF ST Long — side flips to long.
DBHF ST Short — side flips to short.
Adverse Exit Long / Short — K·ATR stop triggers against the current side.
Strengths
Deadbanded baseline reduces micro whipsaws before Supertrend logic even begins.
Flip hysteresis adds a second layer of confirmation at the boundary.
Optional adverse ATR stop provides a uniform risk cut across assets and regimes.
Clear visuals and minimal parameters to adjust for symbol behavior.
Putting it together
Think of this tool as two decisions layered into one view. The deadband baseline answers “does this move even count,” then the Supertrend wrapped around that baseline answers “if it counts, which side should I be on and where do I flip.” When both parts agree you tend to stay on the correct side of a trend for longer, and when they disagree you get an early warning that conditions are changing.
When the baseline bends and price cannot reclaim the opposite band , momentum is usually continuing. Pullbacks into the baseline that stall before the far band often resolve in trend.
When the baseline flattens and the bands compress , expect indecision. Use the Flip Offset ATR to avoid reacting to the first feint. Wait for a clean band breach with follow through.
When an adverse K·ATR exit prints while the side has not flipped , treat it as a risk event rather than a full regime change. Many users cut size, re-enter only if the side reasserts, and let the next flip confirm a new trend.
Final thoughts
Deadband Hysteresis Supertrend is best read as a regime lens. The baseline defines your tolerance for noise, the bands define your trailing structure, and the flip offset plus adverse ATR stop define how forgiving or strict you want to be at the boundary. On strong trends it helps you hold through shallow shakeouts. In choppy conditions it encourages patience until price does something meaningful. Start with settings that reflect the cadence of your market, observe how often flips occur, then nudge the deadband and flip offset until the tool spends most of its time describing the move you care about rather than the noise in between.
Trend FriendTrend Friend — What it is and how to use it
I built Trend Friend to stop redrawing the same trendlines all day. It automatically connects confirmed swing points (fractals) and keeps the most relevant lines in front of you. The goal: give you clean, actionable structure without the guesswork.
What it does (in plain English)
Finds swing highs/lows using a Fractal Period you choose.
Draws auto-trendlines between the two most recent confirmed highs and the two most recent confirmed lows.
Colours by intent:
Lines drawn from highs (potential resistance / bearish) = Red
Lines drawn from lows (potential support / bullish) = Green
Keeps the chart tidy: The newest lines are styled as “recent,” older lines are dimmed as “historical,” and it prunes anything beyond your chosen limit.
Optional crosses & alerts: You can highlight when price closes across the most recent line and set alerts for new lines formed and upper/lower line crosses.
Structure labels: It tags HH, LH, HL, LL at the swing points, so you can quickly read trend/rotation.
How it works (under the hood)
A “fractal” here is a confirmed pivot: the highest high (or lowest low) with n bars on each side. That means pivots only confirm after n bars, so signals are cleaner and less noisy.
When a new pivot prints, the script connects it to the prior pivot of the same type (high→high, low→low). That gives you one “bearish” line from highs and one “bullish” line from lows.
The newest line is marked as recent (brighter), and the previous recent line becomes historical (dimmed). You can keep as many pairs as you want, but I usually keep it tight.
Inputs you’ll actually use
Fractal Period (n): this is the big one. It controls how swingy/strict the pivots are.
Lower n → more swings, more lines (faster, noisier)
Higher n → fewer swings, cleaner lines (slower, swing-trade friendly)
Max pair of lines: how many pairs (up+down) to keep on the chart. 1–3 is a sweet spot.
Extend: extend lines Right (my default) or Both ways if you like the context.
Line widths & colours: recent vs. historical are separate so you can make the active lines pop.
Show crosses: toggle the X markers when price crosses a line. I turn this on when I’m actively hunting breakouts/retests.
Reading the chart
Red lines (from highs): I treat these as potential resistance. A clean break + hold above a red line often flips me from “fade” to “follow.”
Green lines (from lows): Potential support. Same idea in reverse: break + hold below and I stop buying dips until I see structure reclaim.
HH / LH / HL / LL dots: quick read on structure.
HH/HL bias = uptrend continuation potential
LH/LL bias = downtrend continuation potential
Mixed prints = rotation/chop—tighten risk or wait for clarity.
My H1 guidance (fine-tuning Fractal Period)
If you’re mainly on H1 (my use case), tune like this:
Fast / aggressive: n = 6–8 (lots of signals, good for momentum days; more chop risk)
Balanced (recommended): n = 9–12 (keeps lines meaningful but responsive)
Slow / swing focus: n = 13–21 (filters noise; better for trend days and higher-TF confluence)
Rule of thumb: if you’re getting too many touches and whipsaws, increase n. If you’re late to obvious breaks, decrease n.
How I trade it (example workflow)
Pick your n for the session (H1: start at 9–12).
Mark the recent red & green lines. That’s your immediate structure.
Look for interaction:
Rejections from a line = fade potential back into the range.
Break + close across a line = watch the retest for continuation.
Confirm with context: session bias, HTF structure, and your own tools (VWAP, RSI, volume, FVG/OB, etc.).
Plan the trade: enter on retest or reclaim, stop beyond the line/last swing, target the opposite side or next structure.
Alerts (set and forget)
“New trendline formed” — fires when a new high/low pivot confirms and a fresh line is drawn.
“Upper/lower trendline crossed” — fires when price crosses the most recent red/green line.
Use these to track structure shifts without staring at the screen.
Good to know (honest limitations)
Confirmation lag: pivots need n bars on both sides, so signals arrive after the swing confirms. That’s by design—less noise, fewer fake lines.
Lines update as structure evolves: when a new pivot forms, the previous “recent” line becomes “historical,” and older ones can be removed based on your max setting.
Not an auto trendline crystal ball: it won’t predict which line holds or breaks—it just keeps the most relevant structure clean and up to date.
Final notes
Works on any timeframe; I built it with H1 in mind and scale to H4/D1 by increasing n.
Pairs nicely with session tools and VWAP for intraday, or with supply/demand / FVGs for swing planning.
Risk first: lines are structure, not guarantees. Manage position size and stops as usual.
Not financial advice. Trade your plan. Stay nimble.
Dusk Nexus Alpha 4HDusk Nexus Alpha 4H (After Dark Main)
개요
기반 기술: 시장 에너지 폭발 감지 시스템
최적 시간대: 4시간봉 전용
신호 특성: 극희귀, 고품질
용도: 큰 움직임 초기 포착
테이블 설명
DUSK NEXUS ALPHA 4H | 4H LOCKED
├─ Timeframe: 4H 시간대 확인
├─ VOLATILITY: 변동성 폭발 상태 (Critical/High/Normal)
├─ FLOW: 거래량 급증 상태 (Surge/High/Normal)
├─ MOVEMENT: 가격 변화 크기 (Major/Minor)
├─ DIRECTION: 강한 방향성 확인 (Strong Up/Down/Weak)
├─ RANGE: 가격 범위 비율 (Wide/Narrow)
├─ UP POWER: 상승 연속성 강도 (숫자/최대값)
└─ STATUS: 최종 넥서스 신호 상태
핵심 개념
시장 내 잠재 에너지가 폭발적으로 방출되는 순간 포착
변동성, 거래량, 가격 움직임의 동시 급증 패턴 분석
연속성 확인을 통해 일시적 노이즈와 진짜 신호 구분
Dusk Nexus Alpha 4H (After Dark Main)
Overview
Core Technology: Market energy explosion detection system
Optimal Timeframe: 4-hour charts exclusively
Signal Characteristics: Extremely rare, high quality
Purpose: Early capture of major movements
Dashboard Explanation
DUSK NEXUS ALPHA 4H | 4H LOCKED
├─ Timeframe: 4H timeframe verification
├─ VOLATILITY: Volatility explosion status (Critical/High/Normal)
├─ FLOW: Volume surge status (Surge/High/Normal)
├─ MOVEMENT: Price change magnitude (Major/Minor)
├─ DIRECTION: Strong directional confirmation (Strong Up/Down/Weak)
├─ RANGE: Price range ratio (Wide/Narrow)
├─ UP POWER: Upward continuity strength (number/maximum value)
└─ STATUS: Final nexus signal status
Core Concept
Capturing moments when latent market energy explosively releases
Analysis of simultaneous surge patterns in volatility, volume, and price movement
Distinguishing between temporary noise and genuine signals through continuity verification
Dusk Core Alpha 1HDusk Core Alpha 1H
개요
기반 기술: 동적 가격 밴드 돌파 시스템
최적 시간대: 1시간봉 전용
신호 특성: 단기 반응, 적당한 빈도
용도: 단기 스캘핑, 데이트레이딩
테이블 설명
DUSK CORE ALPHA 1H | 1H LOCKED
├─ Timeframe: 1H 시간대 확인
├─ LOCATION: 동적 밴드 내부/외부 위치
├─ BOUNDARY: 밴드 경계선 돌파 상태
├─ ACTIVITY: 변동성 부스트 확인 (배수)
└─ STATUS: 최종 코어 신호 상태
핵심 개념
시장 변동성에 따라 자동 조절되는 가격 경계선
경계선 돌파 시 추세 전환 가능성 감지
단기 시간대 특화로 빠른 반응성 확보
Dusk Core Alpha 1H (After Dark Main)
Overview
Core Technology: Dynamic price band breakout system
Optimal Timeframe: 1-hour charts exclusively
Signal Characteristics: Short-term response, moderate frequency
Purpose: Short-term scalping, day trading
Dashboard Explanation
DUSK CORE ALPHA 1H | 1H LOCKED
├─ Timeframe: 1H timeframe verification
├─ LOCATION: Position inside/outside dynamic bands
├─ BOUNDARY: Band boundary breakout status
├─ ACTIVITY: Volatility boost confirmation (multiplier)
└─ STATUS: Final core signal status
Core Concept
Price boundaries that auto-adjust according to market volatility
Detection of potential trend reversal upon boundary breakouts
Fast responsiveness specialized for short-term timeframes
Dusk Flux Alpha 4HDusk Flux Alpha 4H (After Dark Main)
개요
기반 기술: 기관 투자자 매매선 추적 시스템
최적 시간대: 4시간봉 전용
신호 특성: 높은 정확도, 적은 빈도
용도: 중장기 스윙 트레이딩
테이블 설명
DUSK FLUX ALPHA 4H | 4H LOCKED
├─ Timeframe: 4H 시간대 확인 (다른 시간대 사용금지)
├─ LOCATION: 현재가의 기관 매매선 대비 위치
├─ RANGE: 기관선으로부터 이탈 정도 (%)
├─ ACTIVITY: 시장 변동성 활성화 상태 (배수)
├─ FLOW: 거래량 급증 확인 (평균 대비 배수)
├─ FORCE: 가격 방향성 모멘텀 (양/음/중립)
└─ STATUS: 최종 플럭스 신호 발생 여부
핵심 개념
대형 기관들의 집단 매매 패턴을 실시간 추적
기관선 이탈 시점에서 개인 투자자 진입 기회 포착
변동성과 거래량 동반 확인으로 신호 정확도 향상
Dusk Flux Alpha 4H (After Dark Main)
Overview
Core Technology: Institutional investor flow tracking system
Optimal Timeframe: 4-hour charts exclusively
Signal Characteristics: High accuracy, low frequency
Purpose: Medium to long-term swing trading
Dashboard Explanation
DUSK FLUX ALPHA 4H | 4H LOCKED
├─ Timeframe: 4H timeframe verification (other timeframes prohibited)
├─ LOCATION: Current price position relative to institutional flow lines
├─ RANGE: Deviation percentage from institutional levels (%)
├─ ACTIVITY: Market volatility activation status (multiplier)
├─ FLOW: Volume surge confirmation (average ratio multiplier)
├─ FORCE: Price directional momentum (positive/negative/neutral)
└─ STATUS: Final flux signal generation status
Core Concept
Real-time tracking of large institutional collective trading patterns
Capturing retail entry opportunities at institutional flow deviation points
Enhanced signal accuracy through combined volatility and volume confirmation
BUY & SELL Probability (M5..D1) - MTFMTF Probability Indicator (M5 to D1)
Indicator — Dual Histogram with Buy/Sell Labels
This indicator is designed to provide a probabilistic bias for bullish or bearish conditions by combining three different analytical components across multiple timeframes. The goal is to reduce noise from single-indicator signals and instead highlight confluence where trend, momentum, and strength agree.
Why this combination is useful
- EMA(200) Trend Filter: Identifies whether price is trading above or below a widely used long-term moving average.
- MACD Momentum: Detects short-term directional momentum through line crossovers.
- ADX Strength: Measures how strong the trend is, preventing signals in weak or flat markets.
By combining these, the indicator avoids situations where one tool signals a trade but others do not, helping to filter out low-probability setups.
How it works
- Each timeframe (M5, M15, H1, H4, D1) generates its own trend, momentum, and strength score.
- Scores are weighted according to user-defined importance and then aggregated into a single probability.
- Proximity to recent support and resistance levels can adjust the final score, accounting for nearby barriers.
- The final probability is displayed as:
- Histogram (subwindow): Green bars for bullish probability >50%, red bars for bearish <50%.
- On-chart labels: Showing exact buy/sell percentages on the last bar for quick reference.
Inputs
- EMA length (default 200), MACD settings, ADX period.
- Weights for each timeframe and component (trend, momentum, strength).
- Optional boost for the chart’s current timeframe.
- Smoothing length for probability values.
- Lookback period for support/resistance adjustment.
How to use it
- A green histogram above zero indicates bullish probability >50%.
- A red histogram below zero indicates bearish probability >50%.
- Neutral readings near 50% show low confluence and may be best avoided.
- Users can adjust weights to emphasize higher or lower timeframes, depending on their trading style.
Notes
- This script does not guarantee profitable trades.
- Best used together with price action, volume, or additional confirmation tools.
- Signals are calculated only on closed bars to avoid repainting.
- For testing and learning purposes — not financial advice.
Multi-Timeframe Dashboard INDIpendence AAZ is a powerful Multi-Timeframe Dashboard that provides real-time readings of:
✔ Market Structure
✔ Market Direction
✔ Entry Signals
This tool is designed for Derivatives (Soy, FCPO, etc.), Forex, Crypto, and Global Markets.
Perfect for new traders and those who do not have the time to study charts in detail.
⚠️ Disclaimer: This indicator is for educational and analytical purposes only. All trading decisions and risks remain with the user.
Longhorn Algo Session LevelsThe Longhorn Algo Session Levels indicator automatically plots key intraday reference points across the Asia, London, and Pre-Market (New York) sessions. It is designed to help traders track session-to-session order flow, liquidity grabs, and directional bias as the trading day develops.
Features
Plots highs and lows for Asia, London, and Pre-Market sessions.
Calculates and displays each session’s Line in the Sand (LIS), defined as the session’s average price.
Marks Previous Day High (PDH) and Previous Day Low (PDL) for daily context.
Session ranges reset automatically with each new trading day (18:00 EST roll).
Fully customizable colors, styles, and line widths for every level.
Labels each level directly on the chart for clear identification.
How to Use
Identify where the New York session opens relative to prior Asia, London, and Pre-Market LIS levels.
Watch for liquidity sweeps around session highs/lows.
Use LIS stacking (Asia vs London vs Pre-Market) to gauge directional bias.
This tool is especially useful for futures, forex, and indices traders who rely on session behavior to anticipate market structure and intraday momentum shifts.
Advanced Crypto Day Trading - Bybit Optimized mapercivEMA RSI ATR MACD trading script strategy with filters for weekdays
NN Crypto Scalping ULTIMATE v6 - MTF mapercivNeural Network Crypto Trading System v6.1
Complete Technical Documentation
Author
: Neural Network Ensemble Trading System
Version
: 6.1 - MTF Corrected & Bias Fixed
Date
: January 2025
Platform
: TradingView PineScript v6
Executive Summary
The
Neural Network Crypto Trading System v6.1
is an advanced algorithmic trading system that combines three specialized neural networks into an intelligent ensemble to generate cryptocurrency trading signals. The system integrates multi-timeframe analysis, crypto-specific optimizations, dynamic risk management, and continuous learning to maximize performance in highly volatile markets.
Key Features:
Ensemble of 3 specialized Neural Networks
(Primary, Momentum, Volatility)
Multi-Timeframe Analysis
with 5 timeframes (5m, 15m, 1h, 4h, 1D)
22 Advanced Features
for each model
Anti-repainting
guaranteed with confirmed data
8 Market Regime
automatic detections
6 Signal Levels
(Strong/Moderate/Weak Buy/Sell)
Professional dashboard
with 15+ real-time metrics
Intelligent alert system
with webhook integration
Aladin 2.1Aladin 2.1 is a refined indicator created to improve clarity in trading decisions by combining structural market analysis with advanced signal management. It is designed to minimize noise, avoid over-trading, and provide traders with disciplined setups across multiple asset classes.
One of the unique strengths of this tool is the Minimum Bars Between Signals. This ensures that once a trade setup occurs, the system won’t instantly fire multiple signals back-to-back. Instead, it introduces a controlled spacing mechanism that helps traders avoid unnecessary whipsaws and focus only on meaningful moves.
Another key element is the Valid Bars After Setup. When a potential opportunity is detected, the confirmation window lasts for a specified number of bars (e.g., 1, 2, or 3). This gives traders flexibility in how they respond to signals , whether they want stricter entries that trigger immediately, or a slightly wider confirmation window that allows for more breathing room.
Market Suitability
Works exceptionally well in ranging markets, whether it’s intraday scalping, short-term setups, or swing trading.
Designed for Forex and Crypto markets but equally adaptable to stocks and indices.
Best used when the market is sideways or balanced.
Note: During strong one-directional trends, counter-trend signals may appear less reliable ,the tool is primarily optimized for range and structured phases.
Key Benefits:
Clear Buy/Sell signals with controlled spacing
Adjustable confirmation window (valid bars)
Helps avoid over-trading and false triggers
Adaptable for scalpers, intraday traders, and swing traders alike
Pro Note: This indicator doesn’t rely on a single calculation method, it integrates multiple layers of logic into one framework, keeping it robust without being overly complicated for the user.
[ClearEdege] Momentum Suites V3 Advanced contrarian momentum analysis with intelligent pivot point integration for precision market timing. Developed for ClearEdge members
*This indicator is not publicly available.
Key Features
Smart Signal System
- Buy Low/Sell High Logic: Identifies oversold conditions for long entries and overbought conditions for short entries
- Multi-Timeframe Confirmation: Incorporates higher timeframe bias for enhanced signal reliability
- Momentum Convergence: Combines RSI, StochRSI, and Bollinger Bands for comprehensive market analysis
Dynamic Pivot Integration
- Classic Pivot Points: Auto-calculated daily/weekly/monthly support and resistance levels
- Pivot Confluence Detection: Signals gain strength when price approaches key pivot levels
- Smart Warning System: Single-alert approach prevents label spam while highlighting critical S/R interactions
Table Dashboard
- Compact Signal Table: Real-time buy/sell signal strength with scoring system
- Market Context: Momentum status, nearest pivot level, volume and trend analysis
- Clean Visual Design: Minimal interface focused on actionable information
Intelligent Alerts
- Approach Warnings: Alerts when price nears resistance with overbought momentum or support with oversold momentum
- Confluence Signals: High-probability setups combining momentum extremes with pivot level proximity
- Single-Shot Logic: Prevents alert fatigue with smart reset mechanisms
Best Use Cases
- Swing Trading: Ideal for identifying major reversal points at key levels
- Risk Management: Clear warning system for potential turning points
- Multi-Asset Analysis: Works across forex, crypto, stocks, and commodities
- All Timeframes: Scalable from 5-minute charts to daily analysis
Designed for traders who value precision over noise - combining classical pivot analysis with modern momentum indicators for superior market timing.
Crypto OI AgregatedCrypto OI Aggregated — Open Interest Aggregator for Crypto Exchanges
General Description
The indicator is designed for comprehensive analysis of Open Interest (OI) across major cryptocurrency exchanges. It consolidates data from multiple platforms, visualizes it as candlestick charts or deltas, and builds tables with breakdowns by exchange and contract type. This allows traders to quickly understand where market interest is concentrated and how the market structure is shifting.
Unlike standard tools that only show data from a single exchange, this indicator provides a full market overview and makes it easy to compare dynamics across different platforms.
⸻
Key Features
• Aggregation of OI data from exchanges: Binance, Bybit, OKX, Bitget, Kraken, HTX, Deribit (feel free to leave a comment if you’d like me to add other exchanges that provide open interest data)
• Support for contract types: USDT.P, USD.P, USDC.P, USD.PM
• Automatic normalization of various OI data formats from different providers
• Display modes:
• OI candlestick chart (total aggregated OI)
• OI Delta (change in OI per bar)
• Full table with detailed data by exchange and contract type
• Short summary table with totals in USD and base assets
• Support for USD or COIN denomination
• Convenient formatting for large numbers
• Customizable colors
⸻
How to Use the Indicator
1. Select Exchanges
In the settings, enable or disable specific exchanges. It is recommended to activate only the ones you need for analysis — this will make the indicator faster.
2. Choose Data Type
• OI — aggregated open interest from selected exchanges.
• OI delta — delta (change in OI compared to the previous bar).
3. Denomination
• USD — values are converted into USD equivalents.
• COIN — values are shown in the base asset (BTC, ETH, etc.).
4. Reading the Chart
• OI candlesticks show the overall OI dynamics.
• Delta histogram highlights how much OI has grown or decreased per bar.
• Colors are fully customizable.
5. Tables
• Enabled via the Show table option.
• Full Table → Rows = exchanges, Columns = contract types. Cells contain OI values in either USD or the base asset, depending on settings. Quickly shows where the main interest is concentrated.
• Short Table → Displays only the total OI values in USD and the base asset.
⸻
Important Notes
• For better readability of large values, two custom formatting functions were implemented. They work similarly to format.volume, but with improved digit grouping and adjustable decimal precision. In the tables, the top row is formatted using format.volume, while the bottom row uses the improved formatting functions for clearer representation.
str(d, n, s) =>
str.substring(d, 0, str.length(d) - n) + '.' + str.substring(d, str.length(d) - n, str.length(d) - (n - 2)) + s
format(_r) =>
d = str.tostring(math.round(_r))
str.length(d) > 9 ? str(d, 9, " B") : str.length(d) > 6 ? str(d, 6, " M") : str.length(d) > 3 ? str(d, 3, " K") : d
⸻
Conclusion: Crypto OI Aggregated is a convenient and powerful tool for cryptocurrency derivatives traders. It enables tracking of OI dynamics across multiple exchanges simultaneously, detecting imbalances between contracts, and identifying signals that are not visible when analyzing a single exchange.