Multitimeframe
Pipnotic HTF BarsDescription:
Pipnotic HTF Bars projects higher-timeframe (HTF) candles to the right of current price so you can “peek ahead” with clean, fixed-width silhouettes. The latest HTF bar updates live until it closes; completed HTF bars are frozen and kept in a tidy row to the right. Bodies inherit up/down colours, wicks sit on the body edge (no line through the body), and transparency/borders are configurable for a lightweight, elegant overlay.
How It Works:
The script reads true HTF opens via request.security and detects new HTF boundaries precisely.
Completed HTF bars are captured with look ahead off and stored; they never repaint.
The current HTF bar uses look ahead on and updates tick-by-tick until the next HTF bar begins.
Each candle is drawn as a fixed bar-index width box and wick, anchored a set number of bars to the right of the chart, then spaced evenly.
Visualization and Management:
Candles are rendered as boxes (bodies) plus edge-wicks (coloured to match the body).
You choose how many completed HTF candles to keep visible; older ones are automatically pruned.
Width, spacing, transparency, and borders make the projection readable without cluttering price.
Designed to stay performant and within TradingView’s shape limits.
Key Features & Inputs:
Higher Timeframe (HTF): W, D, 240, 120, 60, 30, 15.
Live Current Bar: The most recent HTF candle updates until it closes (no duplicate static bar).
Number of Candles: Keep the last N completed HTF candles to the right.
Fixed Projection Geometry:
Projected width (bars) : set a constant visual width per candle.
Gap (bars) : spacing between projected candles.
Right shift : anchor the projection a fixed distance beyond the latest bar.
Styling : Up/Down colours, body transparency, optional borders, wicks coloured same as body and drawn from body edge → high/low (never through the body).
Overlay : Works on any symbol and chart timeframe.
Enhanced Visualization:
Edge-wicks align visually with the close side of the body, producing a crisp, unobstructed read of range (H–L) and direction (O→C).
Fixed widths and even spacing create a timeline-like panel to the right of price, ideal for multi-timeframe context without compressing your main chart.
Transparency lets you “ghost” the projection so LTF price action remains visible beneath.
Benefits of Using the Pipnotic HTF Script:
Instant HTF context without switching charts or compressing the main view.
Non-repainting history: Completed HTF candles are locked the moment a new one starts.
Cleaner decision surface: Edge-wicks and soft transparency reduce visual noise.
Time-saving workflow: Scan upcoming HTF structure at a glance (range, bias, progress).
Configurable & lightweight: Tune width, spacing, and count to fit any layout.
Tip: Using the daily HTF on an hourly or less timeframe and watching as price tests the open of the current day, especially if prices e.g. traded below the open, can provide some great trades as prices move above and retest the open.
Srujan Multi-Timeframe Triple EMAGet up to 3 EMA with Different Time frame Values.
Adjust the settings of the desired time frame, and desired length of the EMA.
Power Line — Adaptive Kalman/JMA - One The Mark TradingWhat this indicator does (in one line)
It plots one adaptive “Power Line” (the active slow MA for your current regime) and flips its colour when the fast crosses the slow after passing a set of precision filters (hysteresis, debounce, slope, ADX, optional HTF alignment). The script also gives you a right-side HUD with Entry / Stop / TP1–TP3 and an optional Mini Dashboard (RSI, ADX strength, candle strength).
Regimes (how the moving averages change by timeframe)
Auto by TF (default):
LTF (≤ LTF max minutes): Kalman(JMA) fast/slow (defaults 3/21). Kalman scope preset = Both (fast + slow smoothed by Kalman for low noise).
MID (≤ MID max minutes): RMA 20/50.
HTF (> MID max minutes): selectable MA 50/200 (EMA/SMA/RMA/WMA).
Manual: choose LTF / MID / HTF explicitly.
Tip: If your chart is very noisy (crypto LTF), keep LTF and leave Kalman scope = Both. For indices on 5–15m, try Fast only if you want slightly earlier flips.
Power Line & flips
The Power Line is the slow curve of your active pair (e.g., JMA 21 on LTF, RMA 50 on MID, etc.).
Green = bull, Red = bear.
A flip only registers when:
fast crosses slow beyond a buffer (flipBufATR × ATR),
the condition holds for debounceBars bars (if > 0),
the slope of the Power Line exceeds slopeMinTick,
ADX ≥ adxMin (if ADX gate on), and
HTF alignment agrees (if enabled).
This reduces tiny back-and-forth whips.
Mini Dashboard (top-right by default)
Trend: current direction (from flips).
RSI: quick read of momentum (Bullish / Neutral / Bearish).
ADX: trend strength buckets (Weak / Trending / Strong).
Candle Strength: current candle body-to-range (±100).
Move it: Settings → Mini Dashboard → Dashboard position.
Use the dashboard to validate a candidate entry (e.g., avoid shorts when RSI is deeply oversold and candle strength is strongly bullish unless you’re fading a spike).
The HUD (Entry / SL / TP1–TP3)
On every confirmed flip the script:
Sets Entry at the signal close (or at the Power Line if you switch Entry price to Basis).
Sets Stop to the internal Adaptive SuperTrend line (not plotted, but shown as a dashed HUD line).
Projects TP1/TP2/TP3 at 1R / 2R / 3R multiples of (Entry – Stop).
Options:
Ratchet entry (while the trend holds) to keep entries sensible if you build in later.
Auto BE at TP1 to move the stop to breakeven after a 1R tag.
Max entry drift (R) to clamp entries that wander too far from current price.
How to take entries (playbooks)
A) Conservative continuation (my default)
When: A fresh flip has printed (new colour), but price is extended.
How:
Wait for a pullback toward the Power Line (or toward the dashed SuperTrend HUD line).
Enter with trend on a supportive candle (e.g., bullish body for longs).
Stop: keep at the HUD Stop.
TPs: scale at TP1, move to BE (toggle on), let a runner to TP2/TP3.
Why: Pullbacks reduce chasing risk and improve RR.
B) Aggressive flip-close
When: High momentum flips with strong dashboard.
How:
Enter on the close of the confirmed flip bar.
Use the HUD Stop.
If ATR is high, consider taking a partial at 0.75–1.0R and move to BE quickly.
Why: Captures fast breaks, but only do it when ADX ≥ threshold and Candle Strength agrees.
C) Retest trigger
When: Flip is in, price retests the Power Line from the new side.
How:
Wait for a tag or small pierce of the Power Line.
Enter on the next candle closing back with trend.
Stop at HUD Stop, standard TP ladder.
Why: Elegant risk; lets the market confirm the new regime.
Using the filters (when to tighten/loosen)
Hysteresis buffer (flipBufATR):
Noisy LTF/crypto: 0.15–0.30.
Cleaner markets/HTF: 0.05–0.15.
Debounce bars (debounceBars):
0 = instant.
1–2 on LTF to avoid micro-spikes.
Slope gate:
slopeLen 5 and slopeMinTick 2 ticks are sensible.
Raise slopeMinTick if you still get sideways flips.
ADX gate:
Start with adxLen 14, adxMin 20–25.
Raise to 30 if you only want strong trends.
HTF alignment:
Enable when you want swing-style trades only with the higher-timeframe tide (e.g., trade 5m only in the direction of 1h Power Line).
Timeframe suggestions
Scalps (1–3m / 5m): LTF regime, Kalman scope = Both, buffer 0.20–0.30, debounce 1–2.
Intraday trends (5–15m / 30m): LTF or MID depending on your thresholds; ADX gate ≥ 20–25.
Swing (1h / 4h / Daily): MID/HTF; consider HTF alignment with one level above (e.g., trade 1h with 4h alignment).
Risk & trade management (simple and robust)
Risk fixed R per trade (e.g., 1% account per R).
Stop: HUD Stop (adaptive ST).
TPs:
TP1 at 1R → take 25–50% → move to BE (toggle Auto BE at TP1).
TP2 at 2R, TP3 at 3R for runners.
If volatility compresses (dashboard ADX “Weak”), either tighten or skip.
Alerts (so you don’t stare at screens)
Enable the built-in alerts:
Bullish flip and Bearish flip (they already respect your filters).
You can add alerts on price crossing TP lines if you’d like (TradingView “Add Alert on Horizontal Line”), or wire custom alerts into the script.
Tuning checklist (if you see too many whips)
Increase flipBufATR (0.2 → 0.3).
Add one more debounceBars.
Raise slopeMinTick.
Increase adxMin to 25–30.
Turn on HTF alignment.
Common pitfalls
Chasing the first flip candle in high ATR spikes without ADX/slope confirmation. Use the Retest or Conservative playbook instead.
Turning off all filters on very low timeframes. Expect noise if you do.
Ignoring the HUD Stop: it’s adaptive; don’t freehand it unless your structure stop is tighter and logical.
Quick start (TL;DR)
Keep Auto by TF on.
Use Conservative entry: wait for pullback to the Power Line after a flip.
Confirm dashboard (RSI not fighting, ADX not “Weak”, candle strength supporting).
Stop at HUD line; TP1 at 1R → BE; scale at TP2/TP3.
If you want fewer but cleaner trades, enable HTF alignment.
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
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.
Stocks Multi-Indicator Alerts (cryptodaddy)//@version=6
// Multi-Indicator Alerts
// --------------------------------------------
// This script combines technical indicators and basic analyst data
// to produce composite buy and sell signals. Each block is heavily
// commented so future modifications are straightforward.
indicator("Multi-Indicator Alerts", overlay=true, max_labels_count=500)
//// === Daily momentum indicators ===
// Relative Strength Index measures price momentum.
rsiLength = input.int(14, "RSI Length")
rsi = ta.rsi(close, rsiLength)
// Money Flow Index incorporates volume to track capital movement.
// In Pine Script v6 the function only requires a price source and length;
// volume is taken from the built-in `volume` series automatically.
mfLength = input.int(14, "Money Flow Length")
mf = ta.mfi(hlc3, mfLength)
// `mfUp`/`mfDown` flag a turn in money flow over the last two bars.
mfUp = ta.rising(mf, 2)
mfDown = ta.falling(mf, 2)
//// === WaveTrend oscillator ===
// A simplified WaveTrend model produces "dots" indicating potential
// exhaustion points. Values beyond +/-53 are treated as oversold/overbought.
n1 = input.int(10, "WT Channel Length")
n2 = input.int(21, "WT Average Length")
ap = hlc3 // typical price
esa = ta.ema(ap, n1) // smoothed price
d = ta.ema(math.abs(ap - esa), n1) // smoothed deviation
ci = (ap - esa) / (0.015 * d) // channel index
tci = ta.ema(ci, n2) // trend channel index
wt1 = tci // main line
wt2 = ta.sma(wt1, 4) // signal line
greenDot = ta.crossover(wt1, wt2) and wt1 < -53
redDot = ta.crossunder(wt1, wt2) and wt1 > 53
plotshape(greenDot, title="Green Dot", style=shape.circle, color=color.green, location=location.belowbar, size=size.tiny)
plotshape(redDot, title="Red Dot", style=shape.circle, color=color.red, location=location.abovebar, size=size.tiny)
//// === Analyst fundamentals ===
// Fundamental values from TradingView's database. If a ticker lacks data
// these will return `na` and the related conditions simply evaluate false.
rating = request.financial(syminfo.tickerid, "rating", period="FY")
targetHigh = request.financial(syminfo.tickerid, "target_high_price", period="FY")
targetLow = request.financial(syminfo.tickerid, "target_low_price", period="FY")
upsidePct = (targetHigh - close) / close * 100
downsidePct = (close - targetLow) / close * 100
// `rating` comes back as a numeric value (1 strong sell -> 5 strong buy). Use
// thresholds instead of string comparisons so the script compiles even when
// the broker only supplies numeric ratings.
ratingBuy = rating >= 4 // buy or strong buy
ratingNeutralOrBuy = rating >= 3 // neutral or better
upsideCondition = upsidePct >= 2 * downsidePct // upside at least twice downside
downsideCondition = downsidePct >= upsidePct // downside greater or equal
//// === Daily moving-average context ===
// 50 EMA represents short-term trend; 200 EMA long-term bias.
ema50 = ta.ema(close, 50)
ema200 = ta.ema(close, 200)
longBias = close > ema200 // price above 200-day = long bias
momentumFavorable = close > ema50 // price above 50-day = positive momentum
//// === Weekly trend filter ===
// Higher timeframe confirmation to reduce noise.
weeklyClose = request.security(syminfo.tickerid, "W", close)
weeklyEMA20 = request.security(syminfo.tickerid, "W", ta.ema(close, 20))
weeklyRSI = request.security(syminfo.tickerid, "W", ta.rsi(close, rsiLength))
// Weekly Money Flow uses the same two-argument `ta.mfi()` inside `request.security`.
weeklyMF = request.security(syminfo.tickerid, "W", ta.mfi(hlc3, mfLength))
weeklyFilter = weeklyClose > weeklyEMA20
//// === Buy evaluation ===
// Each true condition contributes one point to `buyScore`.
c1_buy = rsi < 50 // RSI below midpoint
c2_buy = mfUp // Money Flow turning up
c3_buy = greenDot // WaveTrend oversold bounce
c4_buy = ratingBuy // Analyst rating Buy/Strong Buy
c5_buy = upsideCondition // Forecast upside twice downside
buyScore = (c1_buy?1:0) + (c2_buy?1:0) + (c3_buy?1:0) + (c4_buy?1:0) + (c5_buy?1:0)
// Require all five conditions plus trend filters and persistence for two bars.
buyCond = c1_buy and c2_buy and c3_buy and c4_buy and c5_buy and longBias and momentumFavorable and weeklyFilter and weeklyRSI > 50 and weeklyMF > 50
buySignal = buyCond and buyCond
//// === Sell evaluation ===
// Similar logic as buy side but inverted.
c1_sell = rsi > 70 // RSI above overbought threshold
c2_sell = mfDown // Money Flow turning down
c3_sell = redDot // WaveTrend overbought reversal
c4_sell = ratingNeutralOrBuy // Analysts neutral or still buy
c5_sell = downsideCondition // Downside at least equal to upside
sellScore = (c1_sell?1:0) + (c2_sell?1:0) + (c3_sell?1:0) + (c4_sell?1:0) + (c5_sell?1:0)
// For exits require weekly filters to fail or long bias lost.
sellCond = c1_sell and c2_sell and c3_sell and c4_sell and c5_sell and (not longBias or not weeklyFilter or weeklyRSI < 50)
sellSignal = sellCond and sellCond
// Plot composite scores for quick reference.
plot(buyScore, "Buy Score", color=color.green)
plot(sellScore, "Sell Score", color=color.red)
//// === Confidence table ===
// Shows which of the five buy/sell checks are currently met.
var table status = table.new(position.top_right, 5, 2, border_width=1)
if barstate.islast
table.cell(status, 0, 0, "RSI", bgcolor=c1_buy?color.new(color.green,0):color.new(color.red,0))
table.cell(status, 1, 0, "MF", bgcolor=c2_buy?color.new(color.green,0):color.new(color.red,0))
table.cell(status, 2, 0, "Dot", bgcolor=c3_buy?color.new(color.green,0):color.new(color.red,0))
table.cell(status, 3, 0, "Rating", bgcolor=c4_buy?color.new(color.green,0):color.new(color.red,0))
table.cell(status, 4, 0, "Target", bgcolor=c5_buy?color.new(color.green,0):color.new(color.red,0))
table.cell(status, 0, 1, "RSI>70", bgcolor=c1_sell?color.new(color.red,0):color.new(color.green,0))
table.cell(status, 1, 1, "MF down",bgcolor=c2_sell?color.new(color.red,0):color.new(color.green,0))
table.cell(status, 2, 1, "Red dot", bgcolor=c3_sell?color.new(color.red,0):color.new(color.green,0))
table.cell(status, 3, 1, "Rating", bgcolor=c4_sell?color.new(color.red,0):color.new(color.green,0))
table.cell(status, 4, 1, "Target", bgcolor=c5_sell?color.new(color.red,0):color.new(color.green,0))
//// === Alert text ===
// Include key metrics in alerts so the chart doesn't need to be opened.
buyMsg = "BUY: RSI " + str.tostring(rsi, "#.##") +
", MF " + str.tostring(mf, "#.##") +
", Upside " + str.tostring(upsidePct, "#.##") + "%" +
", Downside " + str.tostring(downsidePct, "#.##") + "%" +
", Rating " + str.tostring(rating, "#.##")
sellMsg = "SELL: RSI " + str.tostring(rsi, "#.##") +
", MF " + str.tostring(mf, "#.##") +
", Upside " + str.tostring(upsidePct, "#.##") + "%" +
", Downside " + str.tostring(downsidePct, "#.##") + "%" +
", Rating " + str.tostring(rating, "#.##")
// Alert conditions use static messages; dynamic data is sent via `alert()`
alertcondition(buySignal, title="Buy Signal", message="Buy conditions met")
alertcondition(sellSignal, title="Sell Signal", message="Sell conditions met")
if buySignal
alert(buyMsg, alert.freq_once_per_bar_close)
if sellSignal
alert(sellMsg, alert.freq_once_per_bar_close)
//// === Watch-out flags ===
// Gentle warnings when trends weaken but before full sell signals.
warnRSI = rsi > 65 and rsi <= 65
warnAnalyst = upsidePct < 2 * downsidePct and upsidePct > downsidePct
alertcondition(warnRSI, title="RSI Watch", message="RSI creeping above 65")
alertcondition(warnAnalyst, title="Analyst Watch", message="Analyst upside shrinking")
if warnRSI
alert("RSI creeping above 65: " + str.tostring(rsi, "#.##"), alert.freq_once_per_bar_close)
if warnAnalyst
alert("Analyst upside shrinking: up " + str.tostring(upsidePct, "#.##") + "% vs down " + str.tostring(downsidePct, "#.##") + "%", alert.freq_once_per_bar_close)
//// === Plot bias moving averages ===
plot(ema50, color=color.orange, title="EMA50")
plot(ema200, color=color.blue, title="EMA200")
//// === Cross alerts for context ===
goldenCross = ta.crossover(ema50, ema200)
deathCross = ta.crossunder(ema50, ema200)
alertcondition(goldenCross, title="Golden Cross", message="50 EMA crossed above 200 EMA")
alertcondition(deathCross, title="Death Cross", message="50 EMA crossed below 200 EMA")
Mutual FVG + Mitigation + AlertsMutual Fair Value Gap;
-Shows FVG's that are mutual between the 4hr and 1hr chart timeframes
-4hr bullish FVG's are light purple coloured, mitigated portion becomes more transparent
-4hr bearish FVG's are dark purple coloured, mitigated portion becomes more transparent
-1hr FVG's(bullish/bearish) are transparent but outlined by a white border
-1hr mitigated FVG portions are transparent cyan colour
-Adjustable lookback range
-Alerts on either "approach" or "entry"
-Viewable on all timeframes 4hrs or less
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.
Fixed Range Volume Profile"Distribution of transaction volume by price group (transaction volume by price block)"
Instructions for use (Professional Manual)
1. a basic concept
By vertical axis (price), shows the cumulative trading volume traded in the segment.
The longer the block, the more transactions took place in that price range.
Colors distinguish between buying/selling strength (green = buying advantage, red = selling advantage).
2. Key components
POC (Point of Control)
→ Longest block (most traded price segment, "key selling point").
VAH / VAL (Value Area High/Low)
→ Top/bottom segments where approximately 70% of the total volume is formed.
→ Role of "Major Support/Resistance".
High Capacity Node (HVN)
→ Significantly higher trading volumes → strong support/resistance.
Low Volume Node (LVN)
→ Low volume section → areas where prices are easily passed.
3. practical application
Find Support/Resistance
The thickest block (POC) is used as a place where prices often rebound/resist.
a trading entry/liquidation strategy
Buy if the price is supported near HVN,
When breaking through the LVN, fast movement (gap movement) can be expected.
break/goal setting
Finger = Under the LVN,
Target = Next HVN.
Judgment of trends
When the block distribution is concentrated above, "Increase to Collection Section"
If you're driven below, you're "in a downtrend to a variance section."
4. Precautions
The volume distribution is "past data based" and is not an indicator of the future.
Rather than using it alone, it is more effective to combine with Fibonacci, trend lines, and candle patterns.
In particular, in the volatile market, the LVN breakthrough → may signal a surge/fall.
In summary, this block indicator is "a map showing the most market participants at any price point".
In other words, it is useful for finding support/resistance as a tool for analyzing sales and establishing the basis for trading strategies.
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.
Rapid Cumulative Delta Proxy (Close vs Close)Rapid Cumulative Delta Proxy (Close vs Close)
1. Summary
This indicator provides a powerful proxy for Cumulative Delta , offering insight into the buying and selling pressure within each candle without requiring access to specialized tick data. It works by analyzing a Lower Timeframe (LTF) of your choice and accumulating the volume based on simple price changes, then displaying the results in a clean, customizable "footprint-style" table on your main chart.
This tool is designed for traders who want to understand the underlying order flow dynamics and see whether buyers or sellers were more aggressive during the formation of a candle.
2. Key Features
Cumulative Delta Proxy: Calculates delta by comparing the close of each LTF bar to the previous one, assigning volume to either buyers or sellers.
Lower Timeframe Analysis: Gives you the flexibility to choose any LTF (e.g., 1-minute, 5-minute, or even seconds) to build your delta analysis, allowing for granular or broad views.
Historical "Footprint" Table: Displays data for the current, developing bar as well as a user-defined number of previous bars, allowing for immediate historical context.
Live Data Monitoring: The top row of the table always shows the real-time, developing values for the current bar.
Full Visual Customization: Provides extensive options to control the table's position, colors, and text styles to perfectly match your chart's theme.
3. Calculation Mechanism
The logic of this indicator is straightforward and transparent. For every single bar on your main (Higher Timeframe) chart, the script performs the following steps:
Data Collection: The script uses the request.security_lower_tf() function to gather all the close and volume data from the user-specified Lower Timeframe that falls within the current HTF bar.
Volume Allocation: It then iterates through each of these LTF bars to determine if it represented buying or selling pressure.
If an LTF bar's close is greater than the close of the previous LTF bar, its entire volume is added to a running total of Buy Volume.
If an LTF bar's close is less than the close of the previous LTF bar, its volume is added to a running total of Sell Volume.
If the closes are identical, the volume is considered neutral and is ignored.
Final Calculations: Once all the LTF bars have been processed, the final metrics for that single HTF bar are calculated:
Delta: This is the net difference between the accumulated volumes. The formula is:
Delta=TotalBuyVolume−TotalSellVolume
Imbalance %: This shows the percentage dominance of buyers or sellers relative to the total activity. The formula is:
Imbalance%= Delta / (TotalBuyVolume+TotalSellVolume) ×100
This entire process repeats for each bar on your chart, with the results stored and displayed in the historical table.
4. Settings Explained
Lower Timeframe: The most important setting. This is the timeframe the script will analyze to calculate delta. It must be a lower interval than your main chart's timeframe.
History Bar Count: Controls how many previous, closed bars of data are displayed in the table below the "Live" bar.
Table Visuals (Group):
Header Colors: Customize the text color for each column header (Buy, Sell, Delta, Imbalance).
Background Colors: Set the colors used for the conditional backgrounds on the Delta and Imbalance columns (Positive, Negative, and Neutral values).
Data Text Style: Control the color and size of all standard text in the table. Placed on one line for convenience.
Table Position: A dropdown menu to place the table in any of nine positions on your chart.
5. Trading Concepts & Examples
This is where the Delta Table truly shines. By comparing the delta data (the "Effort") with the candle on your chart (the "Result"), you can gain powerful insights.
A. Effort vs. Result Analysis
This concept helps you determine if the trading activity is actually succeeding in moving the price.
Confirmation:
High positive delta on a large green candle that closes strong. This confirms the buying pressure was effective and the trend is likely to continue.
High negative delta on a large red candle that closes weak. This confirms the selling pressure was effective.
Divergence (Sign of Reversal):
Absorption: You see very high positive delta, but the candle on the chart is small, with a long upper wick (a shooting star). This is a major warning sign. It means buyers exerted massive effort, but the result was poor because a large seller absorbed all their buying, preventing the price from rising. This often precedes a move down.
Exhaustion: You see very high negative delta, but the candle is small with a long lower wick (a hammer). This means sellers tried their best to push the price down but failed. Their effort was met with strong buying pressure, signaling selling exhaustion and a potential bottom.
B. Identifying Traps (Two-Bar Analysis)
Traps occur when a breakout or breakdown fails, catching traders on the wrong side of the market. The Delta Table makes these easy to spot.
Example of a Bull Trap:
The Bait (Bar 1): A strong green candle breaks above a key resistance level. You look at the table and see a strong positive delta, convincing traders to go long.
The Trap (Bar 2): The very next candle is a powerful red candle that closes back below the resistance level. Now, check the table for this candle—you will often see an equally strong or even stronger negative delta.
Interpretation: The initial breakout buyers are now "trapped." The aggressive negative delta on the second bar confirms that sellers have taken control, and the trapped longs will be forced to sell, fueling a sharper decline.
Example of a Bear Trap:
The Bait (Bar 1): A strong red candle breaks below a key support level, showing a strong negative delta in the table. Traders are convinced to go short.
The Trap (Bar 2): The next candle is a powerful green candle closing back above support, accompanied by a very strong positive delta.
Interpretation: The breakdown has failed. Aggressive buyers have stepped in, "trapping" the short-sellers who must now buy back their positions, adding fuel to the rally.
6. Important Notes
Repainting: This indicator does not repaint. Once a bar on your main chart closes, its calculated values in the historical table are fixed and will not change. The "Live" data row updates in real-time as the current bar forms, which is the intended and expected behavior.
1-Second Timeframe: The script allows for using second-based intervals (e.g., "1S"). Please be aware that access to second-based timeframes on TradingView requires a Premium subscription. If you do not have one, please use a minute-based interval (e.g., "1").
Historic Bars: The script can accommodate large range, does not have any max bar limit. Please be aware that large table will require heavy computing power.
7. Disclaimer
The information provided by this indicator is for educational and informational purposes only and does not constitute financial advice. All trading and investment decisions are your own and should be made with the help of a qualified financial professional. Trading financial markets involves substantial risk, and past performance is not indicative of future results. The author is not responsible for any losses you may incur as a result of using this script.
EMA channelThe script builds EMA by high and low. There is a construction by Heikin-Ashi candles, you can also use a multi-timeframe.
Volumatic Fair Value Gaps [BigBeluga]🔵 OVERVIEW
The Volumatic Fair Value Gaps indicator detects and plots size-filtered Fair Value Gaps (FVGs) and immediately analyzes the bullish vs. bearish volume composition inside each gap. When an FVG forms, the tool samples volume from a 10× lower timeframe , splits it into Buy and Sell components, and overlays two compact bars whose percentages always sum to 100%. Each gap also shows its total traded volume . A live dashboard (top-right) summarizes how many bullish and bearish FVGs are currently active and their cumulative volumes—offering a quick read on directional participation and trend pressure.
🔵 CONCEPTS
FVGs (Fair Value Gaps) : Imbalance zones between three consecutive candles where price “skips” trading. The script plots bullish and bearish gaps and extends them until mitigated.
Size Filtering : Only significant gaps (by relative size percentile) are drawn, reducing noise and emphasizing meaningful imbalances.
// Gap Filters
float diff = close > open ? (low - high ) / low * 100 : (low - high) / high *100
float sizeFVG = diff / ta.percentile_nearest_rank(diff, 1000, 100) * 100
bool filterFVG = sizeFVG > 15
Volume Decomposition : For each FVG, the indicator inspects a 10× lower timeframe and aggregates volume of bullish vs. bearish candles inside the gap’s span.
100% Split Bars : Two inline bars per FVG display the % Bull and % Bear shares; their total is always 100%.
Total Gap Volume : A numeric label at the right edge of the FVG shows the total traded volume associated with that gap.
Mitigation Logic : Gaps are removed when price closes through (or touches via high/low—user-selectable) the opposite boundary.
Dashboard Summary : Counts and sums the active bullish/bearish FVGs and their total volumes to gauge directional dominance.
🔵 FEATURES
Bullish & Bearish FVG plotting with independent color controls and visibility toggles.
Adaptive size filter (percentile-based) to keep only impactful gaps.
Lower-TF volume sampling at 10× faster resolution for more granular Buy/Sell breakdown.
Per-FVG volume bars : two horizontal bars showing Bull % and Bear % (sum = 100%).
Per-FVG total volume label displayed at the right end of the gap’s body.
Mitigation source option : choose close or high/low for removing/invalidating gaps.
Overlap control : older overlapped gaps are cleaned to avoid clutter.
Auto-extension : active gaps extend right until mitigated.
Dashboard : shows count of bullish/bearish gaps on chart and cumulative volume totals for each side.
Performance safeguards : caps the number of active FVG boxes to maintain responsiveness.
🔵 HOW TO USE
Turn on/off FVG types : Enable Bullish FVG and/or Bearish FVG depending on your focus.
Tune the filter : The script already filters by relative size; if you need fewer (stronger) signals, increase the percentile threshold in code or reduce the number of displayed boxes.
Choose mitigation source :
close — stricter; gap is removed when a closing price crosses the boundary.
high/low — more sensitive; a wick through the boundary mitigates the gap.
Read the per-FVG bars :
A higher Bull % inside a bullish gap suggests constructive demand backing the imbalance.
A higher Bear % inside a bearish gap suggests supply is enforcing the imbalance.
Use total gap volume : Larger totals imply more meaningful interest at that imbalance; confluence with structure/HTF levels increases relevance.
Watch the dashboard : If bullish counts and cumulative volume exceed bearish, market pressure is likely skewed upward (and vice versa). Combine with trend tools or market structure for entries/exits.
Optional: hide volume bars : Disable Volume Bars when you want a cleaner FVG map while keeping total volume labels and the dashboard.
🔵 CONCLUSION
Volumatic Fair Value Gaps blends precise FVG detection with lower-timeframe volume analytics to show not only where imbalances exist but also who powers them. The per-gap Bull/Bear % bars, total volume labels, and the cumulative dashboard together provide a fast, high-signal read on directional participation. Use the tool to prioritize higher-quality gaps, align with trend bias, and time mitigations or continuations with greater confidence.
Sequential SMT (QT)Sequential SMT (Quarterly Theory)
Price Divergences Between Correlated Asset Pairs Across Time Quarters
This indicator identifies Sequential SMT patterns - divergences between correlated assets across consecutive time periods. When price action diverges between traditionally correlated pairs, it may signal potential reversals or distribution phases.
How It Works
The indicator divides the trading day into specific time quarters and analyzes price extremes within each period. It compares consecutive quarters to detect divergences:
Bullish Pattern: One asset makes a lower low while its correlated pair makes a higher/equal low
Bearish Pattern: One asset makes a higher high while its correlated pair makes a lower/equal high
This implementation enhances standard divergence detection by:
Analyzing multiple timeframe cycles simultaneously (dual-cycle approach)
Using both wick and body-based analysis for hidden divergences
Incorporating True Open levels as confluence filters
Providing visual quarter/cycle boundaries for context
Key Features
Dual-Cycle Detection
M5 Timeframe: Tracks Daily Cycles (6h) AND 90-minute quarters simultaneously
M1 Timeframe: Tracks 90-minute cycles AND 22.5-minute quarters simultaneously
Both cycle types run concurrently for multiple confluence levels
Divergence Analysis
Standard Patterns: Identifies divergences using full candle ranges
Hidden Patterns: Body-only analysis for concealed divergence detection
5 Configurable Correlation Pairs
Pre-configured with major correlations:
BTC/ETH (Cryptocurrency pairs)
NQ/ES (Index futures)
EUR/GBP (Forex majors)
Gold/Silver (Precious metals)
Custom pair slot
Visual Components
Quarter Boxes: Color-coded Q1-Q4 periods showing price ranges
Cycle Frames: Larger timeframe boundaries for context
SSMT Lines: Connect divergence points between quarters
True Opens: TDO (daily) and TSO (session) reference levels
Dual Labels: Period identification for each timeframe
Trading Application
This indicator is designed to identify divergence patterns that may precede reversals:
Signals are strongest when divergences occur near True Open levels
Multiple timeframe confluence increases signal reliability
Best used in conjunction with other technical analysis methods
The indicator is particularly useful for traders who:
Trade correlated asset pairs
Focus on intraday reversals
Use time-based market structure analysis
Combine multiple confluence factors for entries
Customization
Toggle individual components, adjust colors, control visual density. Configure correlation pairs to match your trading instruments. Debug panel available for detailed analysis.
Important Note
This indicator identifies divergence patterns based on mathematical relationships between correlated assets. Like all technical indicators, it should be used as part of a comprehensive trading approach with proper risk management.
---
Based on time-quarter analysis and correlation divergence concepts. Designed to help identify potential reversal zones through systematic divergence detection across multiple time cycles.
Bullish/Bearish Trend TableMy script will give you a Table in the top right of your screen that automatically tells you the current Trend of Each Timeframe.
3Signal Strategy v2🚀 Discover the Ultimate Trend Indicator 🚀
This advanced tool transforms market analysis into an experience that’s simple, clear, and precise.
Its dynamic trend line uses a smart color-coding system that adapts in real time to price action, showing with total clarity when momentum is bullish or bearish.
✅ Filters out market noise, highlighting only what matters: trend strength, potential reversals, and key continuation zones.
✅ Confirms entries and exits with greater confidence, enhancing your strategy alongside support/resistance and volume tools.
✅ Versatile and customizable: from scalping to swing trading, it adapts to every trader’s style.
In volatile markets, the difference lies in the clarity with which you read opportunities.
With this indicator, you’ll gain the confidence to make faster and more effective decisions.
📈 Turn uncertainty into clarity—and your trading into results.
Multi-Period SMA - flack0xA comprehensive moving average indicator featuring 7 fully customizable SMA periods designed for multi-timeframe trend analysis. Perfect for traders who want to visualize multiple moving average periods simultaneously without cluttering their charts with separate indicators.Key Features:
7 Independent SMAs with default periods: 2, 3, 9, 27, 81, 243, 2187
Individual Customization - Each SMA has its own period, color, line width, and visibility controls
Smart Defaults - Shorter SMAs use thinner lines, longer SMAs use thicker lines for visual hierarchy
Overlay Design - Properly overlays on price data without Y-axis attachment issues
Alert System - Built-in crossover alerts for key SMA levels (9 and 27 period)
SMC OB+HOBSmart Money OB/HOB Indicator — Quick Guide
Use this as a field manual: what you’re seeing, how it’s decided, and which settings to use for different timeframes and trade styles.
What the tool plots
Bullish Order Block (OB) — teal box
The last small down candle before a bullish displacement/BOS. Height = candle body (default) or wick range (if you choose “Wick”).
Pin (small white dot) at the origin candle’s time to make anchoring obvious.
Bearish Order Block (OB) — red box
The last small up candle before a bearish displacement/BOS.
Hidden Order Block (HOB) — same box but yellow-tinted fill
A valid OB with one or more same-bias FVGs “ahead” (i.e., OB sits “behind” inefficiency). These tend to be stronger.
Mitigation state (fill transparency)
Unmitigated (least transparent): price hasn’t meaningfully traded back into the box. Highest priority.
Partial (more transparent): some penetration; still valid.
Full (most transparent): fully consumed; lower priority (optional to hide).
Top-K border — thin white outline
Only the best-scoring OBs/HOBs per direction are drawn to reduce clutter.
Auto-Fibs (optional)
OTE zone (0.62–0.79) — subtle purple band across the current swing leg.
0.618 / 0.705 / 0.786 — thin white horizontal lines. Confluence here adds score.
Trade idea lines (per Top-K block)
Entry — white line (mid/edge per your setting).
Stop — red line (box edge ± your pad).
TP1/TP2 — lime lines, R-based from entry→stop distance.
Label shows LONG/SHORT, entry, SL, TP1, TP2, time-stop (bars).
Note: Fair Value Gaps (FVGs) are tracked internally to classify HOBs and for pruning, not drawn to avoid noise.
How a block is qualified (in plain English)
BOS + Displacement:
Close breaks the recent swing high/low by at least N ticks and the bar shows impulse (body ≥ X·ATR and ≥ Y% of its total range).
(Settings: “Close beyond ≥ ticks”, “Min impulse body (x ATR)”, “Body/TR min %”)
Seed candle:
Look back ≤ N bars for the last opposite small-body candle (body ≤ Z% of its range). That candle’s body/wick becomes the OB height.
(Settings: “Last opposite candle within N bars”, “OB body ≤ % of TR”, “OB height model”)
Hidden OB:
Count same-bias FVGs “ahead”. If ≥ your threshold → tag the OB as HOB.
(Setting: “Require ≥ N same-bias FVGs ahead”)
Mitigation tracking:
As price trades into the box, we compute penetration %, updating unmitigated / partial / full state each bar.
Ranking (Top-K):
Every OB/HOB gets a score: near price, newer, hidden, near fib, and unmitigated boost. We draw only the Top-K per direction.
Inputs you’ll actually tweak
Timeframe
Compute on: Current (uses your chart TF) or Specific (MTF scan).
Process last N bars: reduce for speed, increase to see more history.
Anchoring
Extend: Right, Limited, or Origin only.
Limited draws boxes to a fixed number of bars so charts stay clean.
Show origin pins: Keep on so you always know the source candle.
Structure / BOS (signal frequency vs. quality)
Require FVG on break bar: ON = stricter, OFF = more signals.
Min impulse body (x ATR): higher = stricter.
Body/TR min %: higher = stricter.
Close beyond ≥ ticks: 0–1 for LTF; 1–3 for HTF.
Order Blocks
OB height model: Body (cleaner) or Wick (wider protection).
Last opposite candle within N bars: 3–8 (higher finds more).
OB body ≤ % of TR: 0.35–0.70 (lower = stricter).
Min OB height (ticks): 1–2 (avoid micro slivers).
Expire on first touch: If ON, removes boxes after first reaction.
Hidden OB
Require ≥ N FVGs ahead: 0–1 for LTF (more HOBs), 1–2 for HTF.
Mitigation Filter (what you show)
Toggle Unmitigated / Partial / Full visibility.
For precision trading, keep Unmitigated on; show others while scanning.
Auto-Fibs
Enable fib confluence: On adds score near 0.618/0.705/0.786.
Draw lines / OTE: Visual only; confluence also boosts ranking.
Tolerance (x ATR): how close price must be to count as “near fib”.
Ranking & Draw
Top-K per direction: how many OBs/HOBs you’ll see each side.
Prefer near / newer / hidden / unmitigated: scoring toggles.
Fib boost: how much fib confluence bumps a level.
Trade Ideas
Entry style: 50% of OB (balanced) or OB edge (faster fills).
Stop pad (ticks/ATR): give a little room beyond the box edge.
TP1/TP2 (R): risk-multiple targets (e.g., 1R, 2R).
Time stop (minutes): exit if it doesn’t go in time.
Execution / Alerts (recommended)
Keep on-close workflow: do not enable calc_on_every_tick.
When creating alerts, choose Once per bar close.
How to use it (mechanical checklist)
Scan: Focus on Top-K boxes. HOBs (yellow-tinted) and unmitigated get first look.
Context (optional): If you like, also check HTF structure or obvious liquidity pools (equal highs/lows).
Confluence: Prefer boxes near 0.618/0.705/0.786 or inside the OTE band.
Trigger: Let the bar close. If entry line is touched next, you have a go-signal with a placed stop and R-targets.
Manage: If TP1 hits, move SL to BE. For HOBs, consider a runner (trail under minor swing/FVG) — they often travel further.
Time stop: If it hasn’t moved within N minutes/bars, cut it; don’t babysit.
Preset recipes (copy these settings)
1) Hyper-Scalp (1–3m) — frequent, fast
Structure / BOS:
FVG on break = OFF | Min impulse = 0.6–0.8 | Body/TR = 0.45–0.55 | Close beyond = 0–1
Order Blocks:
Opposite lookback = 5–6 | OB body ≤ 0.55–0.60 | Min height = 1
HOB: Need FVGs = 0–1
Mitigation view: Show Unmit/Partial, optionally Full while scanning
Ranking: Top-K = 4–6, prefer near/new/hidden/unmit = ON, Fib boost = 0.6–1.0
Trade Ideas: Entry = OB edge, Stop pad = 1–2 ticks, Time stop = 5–8 min
Execution: On bar close alerts
2) Intraday (5–15m) — balanced
Structure / BOS:
FVG on break = OFF | Min impulse = 0.8–1.0 | Body/TR = 0.55–0.60 | Close beyond = 1
Order Blocks:
Opposite lookback = 4–5 | OB body ≤ 0.50–0.55 | Min height = 1–2
HOB: Need FVGs = 1
Ranking: Top-K = 3–4, Fib boost = 1.0–1.5
Trade Ideas: Entry = 50%, Stop pad = 2–3 ticks, Time stop = 10–20 min
3) Swing (1H–4H) — selective, higher quality
Structure / BOS:
FVG on break = ON | Min impulse = ≥1.0 | Body/TR = ≥0.65 | Close beyond = 1–3
Order Blocks:
Opposite lookback = 3–4 | OB body ≤ 0.45–0.50 | Min height = 2–4
HOB: Need FVGs = 1–2
Ranking: Top-K = 2–3, Fib boost = 1.5–2.0
Trade Ideas: Entry = 50%, Stop pad = a few ticks + ATR pad, Time stop = few bars
4) HTF (Daily+) — very selective
Keep swing settings, increase Min impulse and Close beyond a bit, reduce Top-K to 1–2.
Priority rules (what to trade first)
HOB over OB
Unmitigated over partial/full
With fib confluence over without
Near price and recent over far/old
Favor levels that follow a sweep (equal highs/lows taken, then return to your box)
If two boxes tie, take the one with the cleaner origin candle and simpler path to TP (fewer nearby obstacles).
Troubleshooting & tips
“I’m not seeing many signals.”
Loosen Structure/BOS (lower ATR and Body/TR), increase Opposite lookback, allow Partial/Full in view, raise Top-K.
“Too many lines/boxes.”
Lower Top-K, use Limited extension (Anchoring), hide Partial/Full, and keep fib lines if you rely on confluence.
“Stuff looks offset.”
Keep origin pins on. Use xloc.bar_time (already in code) and avoid custom time compressions that desync objects.
Execution discipline:
Use on-close alerts. Respect time stops. Size by fixed risk per trade, not fixed leverage.
Swing High/Low Levels (Auto Remove)Plots untapped swing high and low levels from higher timeframes. Used for liquidity sweep strategy. Cluster of swing levels are a magnet for price to return to and reverse. Indicator gives option for candle body or wick for sweep to remove lines.
Trapper Magnifying Glass - Bar Decomposer — Last Visible BarHeadline
Decompose any higher-timeframe bar into lower-timeframe candles directly on the chart. Zoom/pan reactive, session-accurate, auto-fit inset, and compliant with TradingView placement limits.
Quick Start
Add the indicator and choose a Child TF (minutes) (e.g., 1, 5, 10, 15).
The inset follows the last visible bar on your screen. Adjust Right separation / Mini width / Gap / Vertical exaggeration as needed.
Leave Show HUD label OFF by default. Turn it on only if you want a compact readout.
Overview
This tool draws a miniature, on-chart inset of lower-timeframe candles that make up the currently viewed higher-timeframe bar. It stays on the main price chart (not in a separate pane), respects zoom/pan, compresses itself to fit available space, and adheres to TradingView’s 500-bar object placement limit.
The design goal is micro-structure inspection without changing the chart timeframe.
What Makes It Different
On-chart inset (not a separate indicator panel) for true visual context.
Zoom/Pan reactive to the last visible bar — works naturally as you navigate.
Auto-fit logic keeps the inset readable while staying inside TradingView’s future-bars limit.
Session-accurate decomposition: uses TradingView’s own lower-timeframe OHLC, exactly within the parent bar’s time window.
Strictly compliant: no synthetic bars, no repaint tricks, no lookahead.
How It Works
Child data is fetched with request.security_lower_tf(syminfo.tickerid, , open/high/low/close).
Only closed lower-TF bars inside the parent bar’s time window are returned by TradingView.
The script maps each child bar to an inset candle (body + wick) scaled to the parent bar’s price range and placed to the right of the parent’s position.
The inset tracks the last visible bar so it always stays relevant to what you’re inspecting.
Inputs (Defaults)
Timeframes
Child TF (minutes): 1 (min 1, max 1440)
Layout
Right separation (bars): 10
Mini candle width (bars): 2
Gap between mini candles (bars): 0
Vertical exaggeration ×: 1.6
Auto-Fit
Auto-fit inset width: ON
Max bars ahead to use: 120
Minimum mini width: 1
Minimum gap: 0
Style
Bull/Bear colors: ON
Body Bull / Body Bear / Wick Bull / Wick Bear: configurable
Body Fill Opacity (0–100): 12
Outline color: dark grey
Outline width: 1
Wick width: 2
HUD
Show HUD label: OFF (recommended default; enable only when you need a summary)
Session Behavior (Important)
TradingView constructs bars strictly by exchange sessions. For US equities (regular session 09:30–16:00, 390 minutes):
On a 1h chart you will see 7 bars per day:
09:30–10:00 (30 minutes)
10:00–11:00, 11:00–12:00, 12:00–13:00, 13:00–14:00, 14:00–15:00 (five full hours)
15:00–16:00 (full hour)
Decomposing the 09:30–10:00 bar into 1m returns 30 minis (not 60).
Decomposing 10:00–11:00 returns 60 minis, as expected.
The last hour (15:00–16:00) decomposes to 60 minis once they exist (i.e., immediately after each child bar closes). If you are mid-session, you will see only the minis that have closed so far.
This is by design and ensures the inset reflects the true lower-timeframe structure TradingView has for that exact bar window. Nothing is synthesized.
Live vs Confirmed Bars
Confirmed bars (historical) always decompose to a full, correct count of child minis for that parent window.
Live bars (currently forming) only return child minis that have already closed. Mid-hour on a 1h chart with 10m children, you might see 3, 4, or 5 minis depending on elapsed time.
This script’s default experience focuses on the last visible bar and displays whatever the platform provides at that moment. The HUD (when enabled) includes the parent bar duration in minutes to make short session bars explicit.
Auto-Fit and Placement Limits
TradingView prevents drawing objects beyond 500 bars into the future. The inset’s right edge is automatically clamped to stay within that boundary. If the requested number of minis would overflow the allowed space, the script proportionally compresses mini width/gap (down to your configured minimums). If necessary, it draws only as many minis as safely fit — favoring stability over clutter.
Styling Tips
For dense decompositions (e.g., 1m inside 1h), set:
Mini width = 1, Gap = 0, Auto-fit = ON, Right separation = 7–12.
Increase Vertical exaggeration to highlight wick-to-body differences when the parent bar is narrow.
Keep HUD OFF for publishing and screenshots unless you’re highlighting counts or session duration.
Notes & Limitations
Child arrays show closed bars only. No forming mini is displayed to avoid misleading totals.
If you reload a chart or switch symbols/timeframes, the most recent confirmed bar’s arrays may be empty on the very first calculation frame; the script guards against this and will draw on the next update.
The tool is an overlay visualization, not a signal generator; there are no alerts or trading advice.
Performance: heavy decompositions on very fast symbols/timeframes can add many objects. Auto-fit and minimal widths help.
Compliance
Uses only native TradingView data (request.security_lower_tf).
No repainting and no lookahead.
No external feeds, synthetic candles, or hidden calculations that would misrepresent the underlying data.
Fully respects TradingView’s object placement constraints.
Recommended Defaults (for broad usability)
Child TF: 5 or 15 (depending on your HTF).
Right separation: 7–12
Mini width / Gap: 2 / 0 for clarity, 1 / 0 for dense fits.
Auto-fit: ON
HUD: OFF
Troubleshooting
“Why aren’t there 60 one-minute minis in this 1h bar?”
Either the parent bar is a session-short bar (09:30–10:00 = 30 minutes) or you are viewing a live bar mid-hour; only closed minis appear.
Inset clipped or not visible to the right:
Increase Max bars ahead to use (Auto-Fit group), reduce Mini width/Gap, or reduce Right separation.
Nothing draws on first load:
Wait for the next bar update, or navigate the chart so the last visible bar changes; arrays refresh as data becomes available.
Change Log
v1.0 – Initial public release.
On-chart inset, zoom/pan reactive, auto-fit width.
Session-accurate lower-TF decomposition.
HUD label toggle (off by default) with child TF, bar count, and parent duration.
Hardened array handling for confirmed snapshots.
Disclaimer
This script is provided strictly for educational and informational purposes only.
It does not constitute financial advice, investment advice, trading signals, or a recommendation to buy or sell any security, asset, or instrument. Trading and investing involve risk; always do your own research and consult with a licensed financial professional before making decisions.
ICT SIlver Bullet Trading Windows UK times🎯 Purpose of the Indicator
It’s designed to highlight key ICT “macro” and “micro” windows of opportunity, i.e., time ranges where liquidity grabs and algorithmic setups are most likely to occur. The ICT Silver Bullet concept is built on the idea that institutions execute in recurring intraday windows, and these often produce high-probability setups.
🕰️ Windows
London Macro Window
10:00 – 11:00 UK time
This aligns with a major liquidity window after the London equities open settles and London + EU traders reposition.
You’re looking for setups like liquidity sweeps, MSS (market structure shift), and FVG entries here.
New York Macro Window
15:00 – 16:00 UK time (10:00 – 11:00 NY time)
This is right after the NY equities open, a key ICT window for volatility and liquidity grabs.
Power Hour
Usually 20:00 – 21:00 UK time (3pm–4pm NY time), the last trading hour of NY equities.
ICT often refers to this as another manipulation window where setups can form before the daily close.
🔍 What the Indicator Does
Draws session boxes or shading: so you can visually see the London/NY/Power Hour windows directly on your chart.
Macro vs. Micro time frames:
Macro windows → The ones you set (London & NY) are the major daily algo execution windows.
Micro windows → Within those boxes, ICT expects smaller intraday setups (like a Silver Bullet entry from a sweep + FVG).
Guides your trade selection: it tells you when not to hunt trades everywhere, but instead to wait for price action confirmation inside those boxes.
🧩 How This Fits ICT Silver Bullet Trading
The ICT Silver Bullet strategy says:
Wait for one of the macro windows (London or NY).
Look for liquidity sweep → market structure shift → FVG.
Enter with defined risk inside that hour.
This indicator essentially does step 1 for you: it makes those high-probability windows visually obvious, so you don’t waste time trading random hours where algos aren’t active.