Skip to main content

TD Sequential indicator for Python

test PyPI Python Downloads License: MIT

td-sequential computes the TD Sequential indicator in Python on a list of OHLC candles: the TD Setup (the 1 to 9 count, often called TD9), the TD Countdown (1 to 13), the TDST support and resistance levels left by completed setups, and the information-only perfection and price flip flags. It works on crypto, stocks and forex candles of any timeframe, has no dependencies, supports Python 3.9 and later, and has an optional pandas helper.

It follows the plain-English rules in SPEC.md and matches the reference output bar for bar. The free TD Sequential counter on moolish.com shows the current count on a crypto pair without installing anything.

Install

pip install td-sequential
pip install "td-sequential[pandas]"   # optional DataFrame helper

Usage

from td_sequential import compute, latest

# Closed bars only, oldest first. Drop the candle that is still forming.
bars = [
    {"t": 1750032000000, "o": 105594.02, "h": 108952.38, "l": 104980.37, "c": 106794.53},
    # ...
]

result = compute(bars)   # one TdBar record per input bar
now = latest(result)     # summary of the last bar

last = result[-1]
if last.buy_setup == 9:
    print("TD Setup 9 (buy) on", last.t, "resistance", last.resistance)
if last.sell_countdown == 13:
    print("TD Countdown 13 (sell) completed on", last.t)

A bar can be a dict with keys t, o, h, l, c (the long names time, open, high, low, close also work), a (t, o, h, l, c) tuple, or any object with those attributes, for example a named tuple or a dataclass. Missing fields and non-numeric prices raise a clear ValueError or TypeError that names the bar.

pandas

import pandas as pd
from td_sequential.pandas import add_td_sequential

df = pd.read_csv("btcusdt-1d.csv", index_col="time", parse_dates=True)  # open, high, low, close columns
out = add_td_sequential(df)   # returns a copy with td_* columns added
print(out[out["td_buy_setup"] == 9])

Column names are case-insensitive on input. Output columns carry the prefix td_ (change it with prefix=). td_resistance and td_support are NaN when there is no active level.

Output fields

compute() returns a list of frozen TdBar dataclasses, one per input bar, in input order.

Field Type Meaning
t any The bar's timestamp, copied from the input
buy_setup int Buy TD Setup counter (0 or more; exactly 9 marks a setup 9)
sell_setup int Sell TD Setup counter, same meaning
buy_countdown int Signed buy countdown; 13 means just completed; 14 or more means no countdown in progress; negative means paused
sell_countdown int Signed sell countdown, same meaning
resistance float or None Price of the active latest TDST resistance level (plain highest high of the 9 setup bars)
support float or None Price of the active latest TDST support level (plain lowest low of the 9 setup bars)
buy_deferred bool The 13th buy countdown bar was held back by the 13-versus-8 test
sell_deferred bool Same for the sell countdown
buy_perfected bool Buy setup 9 whose bar 8 or 9 low is strictly below the lows of bars 6 and 7 (information only)
sell_perfected bool Sell setup 9 whose bar 8 or 9 high is strictly above the highs of bars 6 and 7 (information only)
bullish_flip bool Price flip: close crosses above the close 4 bars earlier after being below it (information only)
bearish_flip bool The mirror price flip (information only)

The four information-only fields never change a setup, countdown or level value.

latest(result) returns a Latest dataclass: the current setup counts, the countdown in progress per side (CountdownState(count, paused) or None), whether a 13 just completed, the time of the last completed setup 9 and countdown 13 per side, and the active resistance and support. It returns None for an empty result.

Rules in short

  • Setup: a bar counts when its close is lower (buy) or higher (sell) than the close 4 bars earlier. Any bar that does not qualify resets the counter to 0. Counting does not stop at 9.
  • Levels: a buy setup 9 records the highest high of its 9 bars as resistance, a sell setup 9 the lowest low as support (the "TDST levels", using the plain 9-bar high and low). A level is dropped when price closes beyond it or a whole bar sits beyond it.
  • Countdown: starts on the setup 9 bar; a bar counts when its close is at or beyond the low (buy) or high (sell) of the bar 2 bars earlier. It needs an active level, is cancelled by the opposite setup 9, and the 13th bar must pass the 13-versus-8 test.

The full, unambiguous version is in SPEC.md.

Verified against reference data

The test suite replays eight real candle histories (crypto pairs on 4-hour, daily and weekly timeframes, about 500 bars each) and requires every counting field to match the stored reference output on every bar. It also compares all twelve fields with the JavaScript implementation of the same rules on the same bars, and has unit cases for setup, levels, countdown, the 13-versus-8 deferral, perfection and price flips. Run it with pip install -e ".[test]" then pytest.

What is TD Sequential?

TD Sequential is Tom DeMark's method for spotting a stretched run of closes. A TD Setup counts consecutive bars that close beyond the close four bars earlier, and a completed 9 can start a countdown that needs 13 qualifying bars. A 9 or a 13 describes past prices and gives no direction on its own; the TD Sequential guide explains the method, TDST and perfected setups.

Attribution and disclaimer

Moolish is not affiliated with, endorsed by or sponsored by Tom DeMark or DeMARK Analytics. TD Sequential is a method created by Tom DeMark, and DeMARK is a trademark of DeMARK Analytics.

This is educational software, not financial advice. A count describes past prices; it is not a prediction.

Licence

MIT - Copyright (c) 2026 Moolish

Metadata

Release files for td-sequential 1.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for td-sequential 1.0.0
File Size Uploaded Provenance Actions
td_sequential-1.0.0.tar.gz 118.8 kB With provenance Details for td_sequential-1.0.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for td-sequential 1.0.0
File Interpreter ABI Platform Actions
td_sequential-1.0.0-py3-none-any.whl Python 3 none any Details for td_sequential-1.0.0-py3-none-any.whl

Total release size: 128.3 kB

Release files / td_sequential-1.0.0.tar.gz

Download URL td_sequential-1.0.0.tar.gz
Size 118.8 kB
Tags Source
SHA-256 checksum
How to use checksums
31c5afe23b0e11394d7538e75427e6d3f526839e616f3e19d72b8d5701f10569
BLAKE2b-256 checksum
How to use checksums
05f7af81c9df9812cd5cc23e00f4580934c3bb3dd396aba2e539a886b5058625
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 28, 2026.

Transparency log

Release files / td_sequential-1.0.0-py3-none-any.whl

Download URL td_sequential-1.0.0-py3-none-any.whl
Size 9.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
d6c9a672d5fc160fc5be0c0436319ceaeaf0fbb64aa62fbab6694c7a586d4c75
BLAKE2b-256 checksum
How to use checksums
abc0b00db334676b28413326d06198a432196a412ee638e73fea16da44524fe8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 28, 2026.

Transparency log

Security for td-sequential 1.0.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for td_sequential-1.0.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 28, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

1.0.0 This release

2 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page