TD Setup and Countdown

TD Sequential Setup and Countdown.
(c) Andrew Hitchman, 2017. All rights reserved.
An implementation of Tom DeMark's ( Sequential Setup and Countdown indication.
Based on the rules described at

If you make money using this indicator, then please show your appreciation by sending a donation to:
BTC: 1Gy4fZLSTw7WFszFspJzhkbwCsdJqgRq1a
ETH: 0xaadd9e54031fc7a58c35bb79bd4a0ba50a32f94a
Dash: XimNeFbU41ZAHTtraDeZaWQoX4Jdm5az6Z

Setup counts long/short (Encircled number above bar)
Close exceeds the close 4 bars earlier in the direction of the setup.
Setup must be contiguous. It resets if a close fails the test.

'Perfect' setups (Filled encircled 8 or 9 setup above bar)
The high exceeds the high 2 bars earlier in the direction of the setup.

Countdown long/short (Encircled number below bar)
After a complete (9) setup, increment count for each close:
-- above the high of two bars earlier (rising short countdown).
-- below the low of two bars earlier (falling long countdown).
Is not contiguous, but resets if a new reversing setup completes, or if the high or low exceeds the extreme high or low of the triggering setup.
The setup exteme high/low recycles based on the fib rules desccribed.

'Perfect' countdown (Filled encircled 13 countdown below bar)
When the 13th high or low exceeds the close of countdown bar 8

Green for rising setups/countdowns
Red for falling setups/countdowns
Reversible in configuration.

Variations from the rules: Does not implement the 'true high/low' rules. Uses simple high/lows.
Introduces 'perfection', and used this rather than defering the countdown 13.

How to trade:

Works more reliably on longer timeframes, but is functional on any timeframe.
A '9' (or perfect '8') signals a potential reversal. Use with price action and candestick patterns and other trends & indicators for support analysis.
A '13' countdown is a stronger reversal indicator, with the same caveats as above.
A '13' on or near a '9' setup is an extremely strong signal.
'9' setups or '13' countdowns across multiple timeframes are the best possible signal. e.g. a monthly 9, a weekly 9, a daily 9.

Bug Reports / Issues:
Please report bugs, isssues or suggest improvements by PM on Trading View

Change History:
24.0 Initial development and first publication
Release Notes: Fix bug where countdown completion and setup completion on the same bar would prevent new countdown starting
Release Notes: Added TD Setup Trend Support and Resistance
Release Notes: Fixed bug in TDST and countdown recycling. Thanks @cmos.
Release Notes: Option to recycle setup on next bar. Requested by numerous people.
Release Notes: Fix regression to restore countdown to start on the bar that completes setup. Thanks to @fernandofurtado
Release Notes: Small update to prevent countdown 1's from repeating
Release Notes: Added TD Price Flip defaulting to on, gives cleaner setups after price pivots. Minor bug spotted by @fernandofurtado fixed.
Release Notes: TD Risk lines show the potential risk in a trade and a possible stop price. Another bug spotted by @fernandofurtado fixed.
Release Notes: Stricter definition of perfected setups and use of true range for TD Risk all suggested by @fernandofurtado.
Release Notes: Experimental feature: volatility smoothing; considers close in addition to close in setups. Numbers show in black.

Intended to allow for some 'whipsaw' action in volatile assets (e.g. crypto).

Off by default. Enable via format dialog.
Release Notes: Fix breaking change in underlying engine by adding max_bars_back=900 to study.
Release Notes: Add update comment
Ta bort från favoritskript Lägg till som favoritskript


hey man, just want to congratulate you for the awesome TD indicator that you provide for free, really amazing!
i was thinking if there is any way to conect your script to an exchange's API, so the BOT can operate in perfect setups. Did you ever tought about that? sorry for the english. cheers
+5 Svara
Hey @andyhitchman, Nice script... clean coding!

I figured out how to implement deferred Setups and deferred Countdowns in my own TD Sequential script,
... Feel free to copy (public domain) and improve.

Also FYI, I started bumping up against undocumented Pine plotting limits. Here's what I figured out:
* Max plots in one script = 64
* However, if any one plot contains a non-constant parameter (other than series), then Max plots = 32

+5 Svara
@brobear, thanks and thanks for the hints. Your script look pretty neat too.
Zettt brobear
@brobear, Very good to know. Thanks!
It would also be nice to be able to set up alerts for perfect 8s and 9s.
+3 Svara
Wow, by far the best TD I've seen on Tradingview complete with not just TD Setup but also with a correct Countdown (I've seen some w/o Countdown and some with the wrong Countdown). Thank you very much for continually updating!
+2 Svara
andyhitchman kkapdolee
@kkapdolee, thanks. If you have ideas on how to improve then I'll try to add them. I think deferred 13 might be next.
kkapdolee andyhitchman
@andyhitchman, thanks. It would be nice to have aggressive 13 countdown as well. I think that may be more relevant to cryptos than deferred 13.
kkapdolee andyhitchman
@andyhitchman, Actually, what do you mean by deferred 13? Are you talking about putting plus signs in each spot that could have been a 13 but didn't meet the requirement of the close having to be less than/greater than or equal to the low/high of bar 8 AND the low/high having to be less than/greater than or equal to the low/high of bar 11? That would be cool too. Btw, I just made a copy of your code and made some quick changes to add the aggressive 13. Looks to be working correctly but not sure. Here's the additional code.

cdownShortA = na, cdownLongA = na, cdownColourA = na, cdownCountA = na

cdownShortA := (lastCompletedSetup != SHORT or cancelCountdown) ? 0 : (high >= high ? (nz(cdownShortA) % 13) + 1 : nz(cdownShortA) % 13)
cdownLongA := (lastCompletedSetup != LONG or cancelCountdown) ? 0 : (low <= low ? (nz(cdownLongA) % 13) + 1 : nz(cdownLongA) % 13)

cdownCountA := max(cdownShortA, cdownLongA)
cdownColour := cdownShort > 0 ? shortColour : longColour

perfectCountdown := showPerfect and ((cdownShort == 13 and high >= perfect8) or (cdownLong and low <= perfect8))

plotchar(not(perfectCountdown) and showCountdown and cdownCountA == 13 and cdownCountA == 12, title="Countdown 13", char="A", location=location.belowbar, color=cdownColour, transp=0)
plotchar(perfectCountdown and showCountdown and cdownCountA == 13 and cdownCountA == 12, title="Perfect Countdown 13", char="A", location=location.belowbar, color=cdownColour, transp=0)

plotshape(showCountdown and cancelCountdown, title="Countdown broke setup support/resistance", location=location.belowbar, style=shape.xcross, color=cdownColour)

The "A" overlaps with some Countdown numbers on the chart though.
andyhitchman kkapdolee
@kkapdolee, yeah, the plus signs. Nice work with the aggressive 13. If it's ok with you I'll integrate this into my code?
+2 Svara
Hem Aktie-screener Forex-screener Krypto-screener Ekonomisk kalender Hur det fungerar Diagramfunktioner Priser Tipsa en vän Ordningsregler Hjälpcenter Webbsidor och mäklarlösningar Widgets Diagramlösningar Lightweight Charting Library Blogg och nyheter Twitter
Profil Profilinställningar Konto och fakturering Hänvisade vänner Mynt Mina kölappar Hjälpcenter Publicerade idéer Följare Följer Privata meddelanden Chatt Logga ut