T->>I: OnCalculate (new bar closes, prev_calculated > 0)
I->>E: feed the one bar that just closed
E-->>I: 9 and or 13 on that bar?
alt a 9 or 13 and bar time is newer than the last alert and not in the tester
I->>U: pop-up (optional sound, push, e-mail)
else nothing completed, same bar again or tester run
I-->>T: nothing sent
end
```
### How often it counts (measured)
Counts per 1,000 closed bars, default rules, on broker history of EURUSD, GBPJPY, XAUUSD and BTCUSD (H1: 374,992 bars, up
to 100,000 per symbol; H4: 103,893; M15: 25,768 because the M15 history in the tester was shorter). It counts bars only,
not what price does afterwards. Source: [`docs/data/count-frequency.json`](docs/data/count-frequency.json), made by
[`tests/frequency.py`](tests/frequency.py).
```mermaid
xychart-beta
title "Completed setups (9) and countdown 13s per 1,000 closed bars"
x-axis ["M15", "H1", "H4"]
y-axis "per 1,000 bars" 0 --> 30
bar [25.26, 23.9, 26.36]
bar [6.75, 6.15, 6.57]
```
First series: completed 9s (buy plus sell). Second series: completed 13s. About one 9 per 40 bars, and roughly one 9 in four
goes on to a 13 (the rest are cancelled by an opposite setup or a close beyond the setup level, or are restarted). Of the
9s, about 73 to 78% are perfected at these defaults. The counts per bar are close on all three timeframes.
## Non-repainting: the proof and how it was tested
"Non-repainting" is easy to claim. Here is what was actually run. Raw result files are in [`tests/results/`](tests/results).
**1. Implementations compared bar by bar.** The Python reference ([`tests/reference.py`](tests/reference.py)) holds the rules of the stated variant. The MT5 and MT4 indicators were dumped bar by bar (every buffer) in the MetaTrader Strategy Tester (MT4) or by a script (MT5), and [`tests/check_parity.py`](tests/check_parity.py) compared each dump with the reference: setup and countdown numbers must be identical on every closed bar.
Run on this exact code: compile 0 errors, 0 warnings (both editions); MT5 24 dumps and MT4 25 dumps (EURUSD, GBPJPY, XAUUSD, BTCUSD on M15, H1 and H4 with the repository's input sets; MT4 adds an every-tick run on EURUSD H1), all identical to the reference on every closed bar; the repaint probes found 0 closed bars that changed afterwards.
**The wider matrix**, made with the Market builds before this repository was cut from them (the same calculation; four symbols EURUSD, GBPJPY, XAUUSD, BTCUSD, M15, H1 and H4, the repository's input sets), checked here against the same reference:
| | MT5 | MT4 |
|---|---|---|
| dumps compared | 24 | 25 |
| bars compared | 1,009,330 | 509,573 |
| failures | 0 | 0 |
| result | ALL PASS | ALL PASS |
Sources: [`tests/results/parity-wide-run-mt5.txt`](tests/results/parity-wide-run-mt5.txt), [`tests/results/parity-wide-run-mt4.txt`](tests/results/parity-wide-run-mt4.txt). MT5 history starts later than MT4's test history on some pairs, which is why the bar counts differ.
**2. Repaint probe.** An EA records which signal buffers are set on each bar *at the moment it closes*, then reads the same bars again at the end and counts any value that changed. It also counts any signal ever shown on the still-forming bar.
| Run | Closed bars checked | Signals seen at close | Changed afterwards | Signals on the live bar |
Source: [`tests/results/repaint-summary.md`](tests/results/repaint-summary.md). The MT5 probe was run once per build on one symbol and timeframe; the MT4 probe ran on every dump run.
**3. Market validation.** Both Market builds passed the MQL5 Market's automated product validation before publication (this is the Market's own check, not part of this repository).
```mermaid
flowchart LR
R[reference.py<br/>Python rules] --> P
S5[MT5 indicator] --> T5[Tester script<br/>DumpIndicator<br/>every bar to CSV]
**Install from source.** Copy `mql5/Indicators/SequentialCountdown/` into `<terminal data folder>/MQL5/Indicators/` (MT5) or
`mql4/Indicators/SequentialCountdown/` into `<data folder>/MQL4/Indicators/` (MT4), open the `.mq5` or `.mq4` in MetaEditor
and press Compile (F7). Both compile with 0 errors and 0 warnings (checked on a Windows machine with MetaEditor, from a clean scratch folder that holds only these files; the compiled files are not in the
repository). Keep the three files of each edition together: the indicator includes `Seq.mqh` and `SignalAlerts.mqh` from
its own folder. The debug log needs the Chart Kit file as well: copy `mql5/Include/ChartKit/` (MT5) or `mql4/Include/ChartKit/` (MT4) into the `Include` folder of the data folder.
1. Compile the indicator and the test tool for your platform (`tests/mql5/Scripts/DumpIndicator`, or
`tests/mql4/SequentialDump.mq4` with `tests/mql4/Include/IndTest4/Dump4.mqh` in your `MQL4/Include/IndTest4/`; MT5 also
needs `tests/mql5/Include/IndTest/Params.mqh`).
2. Run it in the Strategy Tester (MT4) or as a script (MT5) for each symbol and timeframe, with the input sets in
`tests/configs.tsv` (MT5; the exact `InpParams` strings are in `tests/check_parity.py`) and `tests/mql4/configs.tsv`
(MT4). The tool writes one CSV per symbol and timeframe into a `dump` folder.
3.`python3 tests/check_parity.py <folder that contains dump>` (add `--mt4` for MT4 dumps). It prints PASS or FAIL per
file and an overall result.
4. Repaint: run `tests/mql5/Experts/RepaintProbe` in the MT5 Strategy Tester (every tick); the MT4 test EA writes its
repaint log with the dump.
The price dumps used for the published numbers are not in this repository (they are broker price data).
## Honest limits
- **A count is not a strategy.** No stop-loss, position sizing or exit rules are provided or implied, and the rules were
not optimised or back-tested for profit. A 9 or a 13 says a run of closes completed, nothing about what comes next.
- **No profit or accuracy claim is made.** The only numbers here are about *consistency* (the implementations agree,
numbers do not move) and *frequency* (counts per 1,000 bars).
- **One variant of several.** Other tools cancel, restart or qualify the count differently, so their numbers will differ
from these on the same chart. The variant here is stated above and tested exactly.
- **The count depends on where it starts.** A countdown that was already running before the first loaded bar is not seen,
so the first numbers of a short history can differ from those of a longer one.
- **Frequent 9s.** About one 9 per 40 bars; most are not followed by a 13.
- **Scope of the tests.** Four symbols on M15, H1 and H4 for the Market builds (the same calculation), the repository's input sets, one MT5 repaint run; the code in this repository has so far been compile-checked only, and the MT5 build was not run on a live chart as part of these numbers. Other symbols and timeframes are not covered by the published numbers.
## Licence
Copyright 2026 Allan Niñal (<https://www.allanninal.dev/mql5>). Licensed under the
[PolyForm Noncommercial License 1.0.0](LICENSES/PolyForm-Noncommercial-1.0.0.md): source-available, free for personal
and other noncommercial use, not for commercial use. Each source file has an `SPDX-License-Identifier` line. Text:
[`LICENSE`](LICENSE). The 9-13 count is a publicly described method; the code is original, written from the stated variant
and not a port of any other program. The licence applies to this source, not to anything you build or trade with the
indicator. Trading involves risk; the software is provided as is.