OPEN-SOURCE SCRIPT
ที่อัปเดต: Candlestick Edge Auto-Preset MTF Self-Calibrating

Candlestick Edge only fires a candlestick pattern when it is "rightly placed" — confirmed by a higher-timeframe trend AND by where price sits in the developing volume profile. Then it does what most pattern tools don't: it forward-tests every signal and reports the MEASURED edge per pattern, so you read realized performance instead of a marketing claim.
WHY THIS IS ONE TOOL (not a bundle)
The parts answer one question about one candle: "is this pattern in a place that has historically paid, and does it beat a coin-flip here?"
PATTERN detection says WHAT printed (24 classic candlestick patterns).
HTF ALIGNMENT says whether the bigger trend agrees.
VOLUME-PROFILE POSITIONING says WHERE it printed — reversals only at value-area edges, naked POC, HVN support/resistance, or liquidity sweeps; continuations only through low-volume voids or on a value breakout.
The CALIBRATION SPINE forward-resolves each signal with a triple barrier and reports Hit% vs a matched Base% (Edge) with a Wilson confidence interval, so a placed-and-confirmed pattern can be told apart from a small-sample fluke.
One pattern substrate, one location read, one calibration spine.
MEASUREMENT (the differentiator)
Each signal opens at close with target = ±TP·ATR, stop = ∓SL·ATR, over a fixed horizon. The first barrier touched decides win/loss (same-bar tie counts as the stop — conservative). Base% is the unconditional same-barrier win-rate for that direction. Edge = Hit% − Base%; a "*" marks rows whose Wilson 95% lower bound clears the base rate. A leave-one-out row prices each filter's marginal contribution, and a footer lists only the patterns that are green AND have enough samples to trust in the current configuration.
AUTO PRESET (default on)
Candlestick edges are timeframe-specific. Auto Preset reads the chart's timeframe and switches on the pattern subset plus higher-timeframe distance that performed best for that timeframe in the author's study of NSE index futures, and forces the two filters on. Turn it OFF for full manual research mode: all 24 patterns selectable, filters and HTF distance (3x / 5x / 15x / custom) under your control. Nothing is ever removed — the preset only curates which patterns are active by default per timeframe.
HOW TO USE
Leave Auto Preset on and read the labelled signals (teal = bullish, red = bearish, each tagged with the pattern name). Open "Show scoreboard" to see measured Edge per pattern — trust the EDGE column and the "*", never a raw hit-rate. Best behaviour is on intraday timeframes (1H and below).
ORIGINALITY
Standard techniques are credited below. What is original is the combination: a location-gated pattern engine whose every signal is forward-calibrated, a timeframe-adaptive auto-preset, a leave-one-out filter attribution, and an auto-surfaced tradeable set — measured edge, not asserted.
NON-REPAINT
Signals open on confirmed bars; triple-barrier outcomes resolve on bars AFTER the trigger; all higher-timeframe / lower-timeframe / prior-day-POC requests use lookahead_off and confirmed intrabars. Pivots used by sweeps confirm first.
DATA & MARKETS
Runs on any symbol that reports volume; the developing profile needs volume to be meaningful. Defaults are tuned for intraday index futures. On the Enhanced data tier the delta read uses intrabar aggregation (richer on paid plans) and auto-falls-back to an OHLCV proxy when intrabars aren't served — safe to leave on for any plan.
CONCEPT CREDITS (methods operationalized — original Pine re-derivations)
Candlestick patterns — Nison; pattern-performance framing per Bulkowski
Market / auction profile, POC / Value Area — Steidlmayer; Dalton
Bulk Volume Classification — Easley, Lopez de Prado & O'Hara (2012)
Triple-barrier labelling — Lopez de Prado
Wilson score interval — Wilson (1927)
HONESTY / LIMITS
The profile is an ATR-binned developing session profile (not tick POC). Delta is an estimate (proxy or intrabar reconstruction), not true bid/ask. Reported edge is context measured on loaded history — not a prediction or a promise. The preset defaults were tuned on one instrument over a recent window, so treat them as a well-measured hypothesis, not proven alpha.
Educational tool. Not financial advice — you alone are responsible for your trading decisions.
WHY THIS IS ONE TOOL (not a bundle)
The parts answer one question about one candle: "is this pattern in a place that has historically paid, and does it beat a coin-flip here?"
PATTERN detection says WHAT printed (24 classic candlestick patterns).
HTF ALIGNMENT says whether the bigger trend agrees.
VOLUME-PROFILE POSITIONING says WHERE it printed — reversals only at value-area edges, naked POC, HVN support/resistance, or liquidity sweeps; continuations only through low-volume voids or on a value breakout.
The CALIBRATION SPINE forward-resolves each signal with a triple barrier and reports Hit% vs a matched Base% (Edge) with a Wilson confidence interval, so a placed-and-confirmed pattern can be told apart from a small-sample fluke.
One pattern substrate, one location read, one calibration spine.
MEASUREMENT (the differentiator)
Each signal opens at close with target = ±TP·ATR, stop = ∓SL·ATR, over a fixed horizon. The first barrier touched decides win/loss (same-bar tie counts as the stop — conservative). Base% is the unconditional same-barrier win-rate for that direction. Edge = Hit% − Base%; a "*" marks rows whose Wilson 95% lower bound clears the base rate. A leave-one-out row prices each filter's marginal contribution, and a footer lists only the patterns that are green AND have enough samples to trust in the current configuration.
AUTO PRESET (default on)
Candlestick edges are timeframe-specific. Auto Preset reads the chart's timeframe and switches on the pattern subset plus higher-timeframe distance that performed best for that timeframe in the author's study of NSE index futures, and forces the two filters on. Turn it OFF for full manual research mode: all 24 patterns selectable, filters and HTF distance (3x / 5x / 15x / custom) under your control. Nothing is ever removed — the preset only curates which patterns are active by default per timeframe.
HOW TO USE
Leave Auto Preset on and read the labelled signals (teal = bullish, red = bearish, each tagged with the pattern name). Open "Show scoreboard" to see measured Edge per pattern — trust the EDGE column and the "*", never a raw hit-rate. Best behaviour is on intraday timeframes (1H and below).
ORIGINALITY
Standard techniques are credited below. What is original is the combination: a location-gated pattern engine whose every signal is forward-calibrated, a timeframe-adaptive auto-preset, a leave-one-out filter attribution, and an auto-surfaced tradeable set — measured edge, not asserted.
NON-REPAINT
Signals open on confirmed bars; triple-barrier outcomes resolve on bars AFTER the trigger; all higher-timeframe / lower-timeframe / prior-day-POC requests use lookahead_off and confirmed intrabars. Pivots used by sweeps confirm first.
DATA & MARKETS
Runs on any symbol that reports volume; the developing profile needs volume to be meaningful. Defaults are tuned for intraday index futures. On the Enhanced data tier the delta read uses intrabar aggregation (richer on paid plans) and auto-falls-back to an OHLCV proxy when intrabars aren't served — safe to leave on for any plan.
CONCEPT CREDITS (methods operationalized — original Pine re-derivations)
Candlestick patterns — Nison; pattern-performance framing per Bulkowski
Market / auction profile, POC / Value Area — Steidlmayer; Dalton
Bulk Volume Classification — Easley, Lopez de Prado & O'Hara (2012)
Triple-barrier labelling — Lopez de Prado
Wilson score interval — Wilson (1927)
HONESTY / LIMITS
The profile is an ATR-binned developing session profile (not tick POC). Delta is an estimate (proxy or intrabar reconstruction), not true bid/ask. Reported edge is context measured on loaded history — not a prediction or a promise. The preset defaults were tuned on one instrument over a recent window, so treat them as a well-measured hypothesis, not proven alpha.
Educational tool. Not financial advice — you alone are responsible for your trading decisions.
Release Note
v1.1 — measurement fix + two research-added patterns + rebuilt auto-presetCORRECTNESS FIX (read this first)
Triple-barrier resolution now starts on the bar AFTER entry. Previously a signal
could be evaluated against its own entry bar's high/low (extremes that printed
before the close-entry), which inflated same-bar barrier hits and let MFE/MAE
absorb pre-entry range. Every reported Edge / Hit% / MFE / MAE is now measured
strictly forward, matching the non-repaint statement. Historical numbers WILL
differ from v1.0 because the earlier bias has been removed — this version is the
honest one.
NEW PATTERNS (measured, not asserted)
Inverted Hammer (bullish) — shooting-star geometry taken as a bottom reversal,
fired long in a bullish context.
Black Paper Umbrella (bullish) — hammer geometry with a black/red body, fired long.
Both are calibrated exactly like the existing patterns; the scoreboard now reports
26 patterns. Keep only one of {Hammer, Black Paper Umbrella} on at a time if you
want non-overlapping samples (a red hammer satisfies both).
AUTO-PRESET REBUILT
The per-timeframe winner set and HTF distance are now taken from a full, measured
HTF × pattern sweep rather than the older study. Per-TF defaults:
1m→15x Inverted Hammer · 2m→3x Dark Cloud · 3m→3x Inverted Hammer + Three Black
Crows + Shooting Star · 5m→3x Inverted Hammer + Dark Cloud · 15m→15x Inverted
Hammer + Two Black Gapping · 30m→3x Dark Cloud + Bear Engulfing + Piercing + Two
White Gapping · 1h→5x Dark Cloud.
All 26 patterns remain selectable in manual mode; the preset only curates defaults.
RESEARCH CONTROLS
New "Market regime" selector (Both / Calm only / Panic only) gates the WHOLE
scoreboard — signals, base rate, filter-lift and the * significance — to one
regime, so you can measure a clean per-regime edge.
The bottom-right regime panel was removed; the per-pattern Calm E(N) / Panic E(N)
columns remain in the scoreboard.
ROBUSTNESS / HOUSEKEEPING
Intrabar (Enhanced-tier) delta request hoisted to run every bar for a consistent
series; auto-falls-back to the OHLCV proxy on plans that don't serve intrabars.
Guarded the developing-profile bin width against zero-range inputs; na-guarded the
delta/CVD accumulator; single-pass Wilson interval. Lint-clean (no conditional
ta./request.), request.security calls use lookahead_off, budgets unchanged.
As always: reported edge is context measured on loaded history, not a prediction.
Educational tooling, not financial advice.
Release Note
v1.2 — Correctness + finishing pass- Correctness: the CVD-divergence high/low (ta.highest / ta.lowest) now recalculate on every bar
instead of being skipped during warm-up, per Pine's requirement for series functions. Clears the
compiler warning; no change to signals on loaded history beyond the first few bars.
- Added an adaptive dark/light theme — the scoreboard now stays legible on light charts, not just dark.
- Added a Data Window (EXP_) export bus: signal, regime, HTF bias, delta, CVD, POC/VAH/VAL, ATR — so
the script's context can feed other indicators via input.source().
- Added a cost model: a new "Round-trip cost (R)" input and a Net R column. The TRADEABLE footer now
requires a pattern to BOTH clear its base rate (Wilson) AND post a positive net R after cost — a
gross win-rate edge that costs eat through is not tradeable, and the panel now says so.
As always: descriptive research tooling, in-sample, not investment advice.
สคริปต์โอเพนซอร์ซ
ด้วยเจตนารมณ์หลักของ TradingView ผู้สร้างสคริปต์นี้ได้ทำให้เป็นโอเพนซอร์ส เพื่อให้เทรดเดอร์สามารถตรวจสอบและยืนยันฟังก์ชันการทำงานของมันได้ ขอชื่นชมผู้เขียน! แม้ว่าคุณจะใช้งานได้ฟรี แต่โปรดจำไว้ว่าการเผยแพร่โค้ดซ้ำจะต้องเป็นไปตาม กฎระเบียบการใช้งาน ของเรา
คำจำกัดสิทธิ์ความรับผิดชอบ
ข้อมูลและบทความไม่ได้มีวัตถุประสงค์เพื่อก่อให้เกิดกิจกรรมทางการเงิน, การลงทุน, การซื้อขาย, ข้อเสนอแนะ หรือคำแนะนำประเภทอื่น ๆ ที่ให้หรือรับรองโดย TradingView อ่านเพิ่มเติมใน ข้อกำหนดการใช้งาน
สคริปต์โอเพนซอร์ซ
ด้วยเจตนารมณ์หลักของ TradingView ผู้สร้างสคริปต์นี้ได้ทำให้เป็นโอเพนซอร์ส เพื่อให้เทรดเดอร์สามารถตรวจสอบและยืนยันฟังก์ชันการทำงานของมันได้ ขอชื่นชมผู้เขียน! แม้ว่าคุณจะใช้งานได้ฟรี แต่โปรดจำไว้ว่าการเผยแพร่โค้ดซ้ำจะต้องเป็นไปตาม กฎระเบียบการใช้งาน ของเรา
คำจำกัดสิทธิ์ความรับผิดชอบ
ข้อมูลและบทความไม่ได้มีวัตถุประสงค์เพื่อก่อให้เกิดกิจกรรมทางการเงิน, การลงทุน, การซื้อขาย, ข้อเสนอแนะ หรือคำแนะนำประเภทอื่น ๆ ที่ให้หรือรับรองโดย TradingView อ่านเพิ่มเติมใน ข้อกำหนดการใช้งาน