Candlestick scanners become difficult to trust when a pattern name is the only evidence they return. This tutorial builds the missing contract around one question: How can one scan many instruments without accepting disabled, provisional, future-known, or weak detector hits? By the end, you can dispatch a frozen registry across injected detector candidates and emit only causal occurrence records with explicit rejection reasons and verify the same result in Python and TypeScript.
Begin with the decision, not the chart decoration
The scanner is orchestration, not a new pattern detector. It applies the same eligibility gates to every instrument and records why candidates were skipped. TA-Lib’s official catalog demonstrates that many candlestick detectors can share an OHLC-array interface, while its API supports both whole-array and streaming execution (function catalog, core API). Our task is not to imitate undocumented vendor settings. It is to make the scanner boundary observable.
The selected formula is:
The comparison is inclusive, the remaining tie-breaks are stable, and unavailable evidence never becomes a convenient zero. Those are implementation choices. They make behavior testable; they do not prove a market edge.
Follow the data contract
The canonical input and output tables live in the topic README. Preserve source-qualified instrument identity, interval and session, price basis, detector version, event time, availability time, and closed-bar state. Binance’s official kline stream shows why finality must be explicit: its payload distinguishes an updating bar from a closed one (provider schema). The exact fields differ across providers, so adapt at ingestion and keep the algorithm provider-neutral.
What to notice: validation and time eligibility happen before the decision. A plausible pattern found with later information is still invalid for a point-in-time scan.
Open the accessible full-size diagram. The guided lab lets you step through canonical, equality-boundary, and rejected states with reduced-motion support.
Recalculate the fixture
Three injected candidates produce one occurrence: the closed 0.90 match passes, a live bar is rejected, and a 0.60 match fails the 0.80 inclusive threshold. This is labeled synthetic teaching data. The stored expected values were frozen independently of either implementation; both languages must match them within 1e-9 for numbers and exactly for identifiers, arrays, booleans, reason codes, and states.
Implement one source of scanner semantics
The topic-specific Python and TypeScript entry points delegate to a shared D06-F05 family core. That architecture prevents nine packages from inventing nine versions of finite-number checks, inclusive boundaries, and error semantics. It does not hide the topic algorithm: each public wrapper names exactly one core function, and the canonical README freezes its behavior before derivatives.
Run the Python test with python tests/test_market_scanner.py and the TypeScript test with node --test tests/market_scanner.test.ts from the topic folder. The shared fixture is the cross-language oracle.
Interpret the result carefully
A detector can match geometry, the context can score highly, confirmation can occur, and the ranked alert can still lose money. Lo, Mamaysky, and Wang’s computational work is useful here because it separates systematic recognition from an empirical evaluation design (NBER Working Paper 7613). A production claim needs point-in-time universe membership, survivorship controls, costs, multiple-testing controls, out-of-sample data, and uncertainty. This tutorial claims only reproducible infrastructure behavior.
Failure checklist
- Reject provisional terminal bars and future-known levels.
- Do not mix raw and adjusted prices or incompatible session calendars.
- Preserve warm-up, zero-scale, invalid, suppressed, and expired states.
- Version definitions before changing thresholds or precedence.
- Keep ranking scores distinct from probabilities and expected returns.
- Retain reason codes so an operator can explain every accepted or rejected event.
What comes next
Continue through the related topics listed in the canonical package. Together the family moves from a stable detector registry to occurrence evidence, causal scanning, context, conflict handling, confirmation, and final ranked deduplicated output. Full sources and applicability boundaries are in REFERENCES.md.
Rendered from the canonical Mermaid sources linked by this article.
Decision flow
Purpose: show the causal position of Market-Wide Candlestick Pattern Scanner.
Takeaway: the output records both the decision and the evidence boundary.
ReferencesPrimary sources and evidence notesExpand the source trail, evidence role, and limitations behind the engineering choices.
Expand the source trail, evidence role, and limitations behind the engineering choices.
SRC-01 — TA-Lib function catalog and pattern-recognition group
- Organization or authors: TA-Lib project
- Source type: Official maintained function documentation
- Publication or effective date: Continuously maintained
- Version: Website state accessed 2026-08-01
- URL or DOI: https://ta-lib.org/functions/
- Accessed: 2026-08-01
- Jurisdiction: Software documentation; not market regulation
- Supports: Pattern recognition is a distinct function category; documented functions consume OHLC arrays and may be dispatched programmatically.
- Limitations: TA-Lib's names and outputs do not define this package's registry metadata, thresholds, scores, conflict policy, or state machine.
SRC-02 — TA-Lib C/C++ Core API
- Organization or authors: TA-Lib project
- Source type: Official API documentation
- Publication or effective date: Continuously maintained
- Version: Website state accessed 2026-08-01
- URL or DOI: https://ta-lib.org/api/
- Accessed: 2026-08-01
- Jurisdiction: Software documentation
- Supports: The library distinguishes batch array processing, streaming, and dynamic abstraction-layer dispatch.
- Limitations: This family is dependency-free and does not claim TA-Lib numerical parity.
SRC-03 — Binance Spot kline/candlestick stream
- Organization or authors: Binance
- Source type: Official provider API documentation
- Publication or effective date: Continuously maintained
- Version: Website state accessed 2026-08-01
- URL or DOI: https://developers.binance.com/docs/binance-spot-api-docs/web-socket-streams#klinecandlestick-streams-for-utc
- Accessed: 2026-08-01
- Jurisdiction: Provider-specific spot-market data
- Supports: A provider kline message can expose open/close times, OHLC, volume, trade counts, and an explicit closed-bar flag.
- Limitations: Field meaning, interval calendars, revision behavior, and licensing are provider-specific; the synthetic fixture is not Binance market data.
SRC-04 — CME Group chart types and support/resistance lessons
- Organization or authors: CME Group
- Source type: Official exchange education
- Publication or effective date: Continuously maintained
- Version: Website state accessed 2026-08-01
- URL or DOI: https://www.cmegroup.com/education/courses/technical-analysis/chart-types-candlestick-line-bar
- Accessed: 2026-08-01
- Jurisdiction: General market education
- Supports: Candlesticks encode OHLC and practitioners commonly interpret them with trend, volume, support, and resistance context.
- Limitations: Educational descriptions do not prescribe universal detector thresholds or validate forecasting value.
SRC-05 — Foundations of Technical Analysis
- Organization or authors: Andrew W. Lo, Harry Mamaysky, and Jiang Wang
- Source type: Original academic working paper and Journal of Finance article
- Publication or effective date: 2000
- Version: NBER Working Paper 7613
- URL or DOI: https://doi.org/10.3386/w7613
- Accessed: 2026-08-01
- Jurisdiction: Empirical U.S. equities study for its declared historical sample
- Supports: Subjective chart recognition can be translated into systematic computational rules; empirical usefulness requires a separate study design.
- Limitations: It does not validate this family’s candlestick rules, weights, universe, or current predictive performance.
Evidence and licensing boundary
The external sources support data fields, software organization, common contextual concepts, and the need for systematic definitions. Every numeric weight, inclusive comparison, tie-break, expiry rule, and synthetic value in this package is an implementation choice or author-derived calculation. The fixtures are synthetic and CC0-1.0; no provider observations are redistributed.
Full dependency-light reference implementations in both supported languages.
/** Topic entry point for Market-Wide Candlestick Pattern Scanner. */
export { scanMarket } from "../../../f05Core.ts";
import { scanMarket } from "../../../f05Core.ts";
export function calculateTopic(data: Record<string, unknown>) { return scanMarket(data); }
The embedded lab now expands to its full document height, keeping the article as the only scroll surface.