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
Notas de Lançamento: Fix bug where countdown completion and setup completion on the same bar would prevent new countdown starting
Notas de Lançamento: Added TD Setup Trend Support and Resistance
Notas de Lançamento: Fixed bug in TDST and countdown recycling. Thanks @cmos.
Notas de Lançamento: Option to recycle setup on next bar. Requested by numerous people.
Notas de Lançamento: Fix regression to restore countdown to start on the bar that completes setup. Thanks to @fernandofurtado
Notas de Lançamento: Small update to prevent countdown 1's from repeating
Notas de Lançamento: Added TD Price Flip defaulting to on, gives cleaner setups after price pivots. Minor bug spotted by @fernandofurtado fixed.
Notas de Lançamento: TD Risk lines show the potential risk in a trade and a possible stop price. Another bug spotted by @fernandofurtado fixed.
Notas de Lançamento: Stricter definition of perfected setups and use of true range for TD Risk all suggested by @fernandofurtado.
Notas de Lançamento: 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.
Notas de Lançamento: Fix breaking change in underlying engine by adding max_bars_back=900 to study.
Notas de Lançamento: Add update comment
Notas de Lançamento: Fix issue found by namecnp where perfected countdowns were not correctly determined due to cd 8 being carried.
Notas de Lançamento: Fix issue where countdown is created in first bars of chart even when there has been no setup (thx namecnp).
Script de código aberto

No verdadeiro espírito TradingView, o autor deste script o publicou com código aberto, para que os traders possam compreendê-lo e verificá-lo. Um brinde ao autor! Você pode usá-lo gratuitamente, mas a reutilização deste código em uma publicação é regida pelas Regras da Casa. Você pode favoritá-lo para utilizá-lo em um gráfico.

Quer usar esse script no gráfico?


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

+8 Resposta
@brobear, thanks and thanks for the hints. Your script look pretty neat too.
Zettt brobear
@brobear, Very good to know. Thanks!
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 Resposta
It would also be nice to be able to set up alerts for perfect 8s and 9s.
+4 Resposta
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 Resposta
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 Resposta