DeMark TD Sequential Counter
TD Sequential is the most requested DeMark tool on every MQL forum and almost never done properly, because the counting rules are easy to state and easy to get subtly wrong. This submission implements the two-phase count as it is documented across public DeMark literature: Setup counts a run of up to 9 consecutive closes each below (Buy Setup) or above (Sell Setup) the close 4 bars earlier, and any bar that breaks the run resets that side to zero. Once a Setup reaches 9, Countdown begins - it counts bars, not necessarily consecutively, where the close is at or below the low 2 bars earlier (Buy Countdown) or at or above the high 2 bars earlier (Sell Countdown), up to 13, and only stops early if the opposite Setup completes first. Read the notes and limitations section before trusting this near a real DeMark chart: the official ruleset also has "recycle" behaviour (a fresh opposing Setup restarts an active Countdown under certain conditions) and bar-8/13 price qualifiers that this build does not implement. What is here is the core count that almost every public TD Sequential reimplementation - on this platform or any other - actually reproduces, and it is stated plainly rather than dressed up as the complete official ruleset. Notes and limitations - Recycle rules are not implemented: DeMark's official method restarts an active Countdown under certain new-Setup conditions beyond the simple "opposite Setup hits 9 cancels this Countdown" rule used here. - The bar-8/bar-13 price qualifiers that mark a "perfect" 13 (used by some traders to judge Countdown quality) are not implemented; every 13 is reported the same way regardless of qualifier status. - Setup and Countdown are strict bar-by-bar state machines carried in memory between ticks; loading a very long history triggers a full recount from the oldest kept bar, which is a one-off cost on chart open. - Fully causal: a count only advances on the close of bar 1 (the most recently closed bar), never on bar 0, so nothing here can repaint.
Indicator · MT4 · v1.0 · Free
About DeMark TD Sequential Counter
DeMark TD Sequential Counter is an indicator for MetaTrader 4. It can alert you with a pop-up, sound, email or push message. It has 7 settings, such as Buy setup color, Sell setup color and Buy count color. MQL source code included.
Files in the download: DemarkTdSequentialCounter.ex4, DemarkTdSequentialCounter.mq4, DemarkTdSequentialCounter.txt.
Settings
| Setting | Default | What it does |
|---|---|---|
| Buy setup color | clrLime | Buy Setup count colour |
| Sell setup color | clrRed | Sell Setup count colour |
| Buy count color | clrDeepSkyBlue | Buy Countdown count colour |
| Sell count color | clrOrange | Sell Countdown count colour |
| Font size | 8 | Label font size |
| Max labels | 400 | Bars back to keep numbered (performance guard) |
| Alerts | true | Alert on Setup 9 and Countdown 13 |
How to install
- Download the ZIP from your PolyMaria library and unzip it.
- In MetaTrader 4 open File → Open Data Folder, then go to MQL4 → Indicators.
- Copy the .mq4 file(s) there. Put any .mqh files in MQL4 → Include.
- Open the .mq4 file in MetaEditor and press Compile (F7) if MetaTrader does not show it.
- Drag the indicator from the Navigator onto a chart and adjust the settings.
Tags: Alerts · MT4 Indicator · MQL4 Source Code