Ftd Detector
ASecurityDetects Follow-Through Day (FTD) signals for market bottom confirmation using William O'Neil's methodology. Dual-index tracking (S&P 500 + NASDAQ) with state machine for rally attempt, FTD qualification, and post-FTD health monitoring. Use when user asks about market bottom signals, follow-through days, rally attempts, re-entry timing after corrections, or whether it's safe to increase equity exposure. Complementary to market-top-detector (defensive) - this skill is offensive (bottom confirma...
- 9,709 stars
- 0 votes
- 0 copies
- 1 view
- Added December 4, 2026
Works with
Security analysis
100/100Pro scans all 13 files and shows the line behind each finding
npx -y skills add tradermonty/claude-trading-skills --skill ftd-detector --agent claude-codeAre you the author of Ftd Detector?
Add the live security badge to your README. It updates with every re-scan.
[](https://www.skillsdirectory.com/skills/tradermonty-ftd-detector)---
name: ftd-detector
description: Detects Follow-Through Day (FTD) signals for market bottom confirmation using William O'Neil's methodology. Dual-index tracking (S&P 500 + NASDAQ) with state machine for rally attempt, FTD qualification, and post-FTD health monitoring. Use when user asks about market bottom signals, follow-through days, rally attempts, re-entry timing after corrections, or whether it's safe to increase equity exposure. Complementary to market-top-detector (defensive) - this skill is offensive (bottom confirmation).
---
# FTD Detector Skill
## FTD lifecycle and evidence contract (#765)
- Keep the FTD event separate from its current health. A close below the FTD-day low is a warning, not automatic rally failure. A later intraday low strictly below the rally low (the low of the pullback the rally attempt started from, frozen on Day 1; not the lowest low of the whole correction) fails that rally, before and after an FTD; equality holds. Day 1 low is informational only, not an interchangeable failure level.
- Missing/non-finite/nonpositive low evidence on any replayed bar means unavailable. Never substitute a close for a missing low.
- Default Nasdaq evidence is `^IXIC` (Composite). Use `--nasdaq-symbol QQQ` only for a labeled Nasdaq-100 ETF proxy. Never substitute its volume or price into an index series or claim its DD count is the Composite count. No automatic fallback.
- `quality_score` is an uncalibrated technical heuristic, not success probability. `exposure_range` is `Not assessed` in every state. Do not derive portfolio percentages from the score; assess breadth, leadership, portfolio limits and operator decisions separately.
- Day 4–10 is this model's FTD window. An attempt that reaches Day 11 without an FTD expires (RALLY_FAILED) and a new segment starts at that bar, so the next count's reference low is the lowest low from the expiry bar through its Day 1. The expiry bar is never Day 1, and a down close arms the new count (while not armed a bar can only arm it). IBD is reported to note that most FTDs come on days 4-7 and some come later (secondary report, IBD's official rule text not verified), so a later FTD is not modelled.
## Purpose
Detect Follow-Through Day (FTD) signals that confirm a market bottom, using an explicit O'Neil-style technical model. Generates a quality score (0-100) with technical health warnings; portfolio exposure is not assessed.
**Complementary to Market Top Detector:**
- Market Top Detector = defensive (detects distribution, rotation, deterioration)
- FTD Detector = offensive (detects rally attempts, bottom confirmation)
## When to Use This Skill
**English:**
- User asks "Is the market bottoming?" or "Is it safe to buy again?"
- User observes a market correction (3%+ decline) and wants re-entry timing
- User asks about Follow-Through Days or rally attempts
- User wants to assess if a recent bounce is sustainable
- User asks about increasing equity exposure after a correction
- Market Top Detector shows elevated risk and user wants bottom signals
**Japanese:**
- 「底打ちした?」「買い戻して良い?」
- 調整局面(3%以上の下落)からのエントリータイミング
- フォロースルーデーやラリーアテンプトについて
- 直近の反発が持続可能か評価したい
- 調整後のエクスポージャー拡大の判断
- Market Top Detectorが高リスク表示の後の底打ちシグナル確認
## Difference from Market Top Detector
| Aspect | FTD Detector | Market Top Detector |
|--------|-------------|-------------------|
| Focus | Rally-event confirmation | Market deterioration assessment |
| Trigger | Market correction (3%+ decline) | Market at/near highs |
| Signal | Rally attempt → FTD → health assessment | Distribution → deterioration evidence |
| Score | 0-100 heuristic FTD quality | Separate heuristic market-risk score |
| Action | When technical confirmation appears | When deterioration appears |
---
## Execution Workflow
### Phase 1: Execute Python Script
Run the FTD detector script:
```bash
python3 skills/ftd-detector/scripts/ftd_detector.py --api-key $FMP_API_KEY
```
The script will:
1. Fetch S&P 500 (^GSPC) and Nasdaq Composite (^IXIC) historical data (500 trading sessions; the whole history is replayed) from FMP API
2. Fetch current quotes for both indices
3. Run dual-index state machine (correction → rally → FTD detection)
4. Assess post-FTD health (distribution days, invalidation, power trend)
5. Calculate quality score (0-100)
6. Generate JSON and Markdown reports
**API Budget:** 4 calls (well within free tier of 250/day)
### Phase 2: Present Results
Present the generated Markdown report to the user, highlighting:
- Current market state (correction, rally attempt, FTD confirmed, etc.)
- Quality score and signal strength
- Exposure not assessed: breadth, leadership and portfolio risk require separate inputs
- Key watch levels (swing low, FTD day low)
- Post-FTD health (distribution days, power trend)
### Phase 3: Contextual Guidance
Based on the market state, provide additional guidance:
**If FTD Confirmed (score 60+):**
- Suggest looking at leading stocks in proper bases
- Reference CANSLIM screener for candidate stocks
- State that portfolio sizing and stop placement are not assessed by this score
**If Rally Attempt (Day 1-3):**
- Advise patience, do not buy ahead of FTD
- Suggest building watchlists
**If No Correction:**
- FTD analysis is not applicable in uptrend
- Redirect to Market Top Detector for defensive signals
---
## State Machine
The model replays the whole supplied history (500 sessions are fetched) oldest to
newest and carries state, so a confirmed FTD stays confirmed until a defined event ends
it and the result does not depend on a window length.
```
NO_SIGNAL → CORRECTION → RALLY_ATTEMPT → FTD_WINDOW → FTD_CONFIRMED
↑ ↓ ↓ ↓
└── RALLY_FAILED ←─────────────┘ FTD_INVALIDATED
```
`market_status` maps the states onto IBD's three tiers (additive field on every
`analyze_single_index` result, per index in the JSON, and combined in `market_state`):
| market_status | Legacy states |
|---------------|---------------|
| `confirmed_uptrend` | FTD_CONFIRMED or UPTREND_RESUMED |
| `uptrend_under_pressure` | FTD_CONFIRMED or UPTREND_RESUMED (`cycle.uptrend_status` = `under_pressure`) |
| `market_in_correction` | CORRECTION, RALLY_ATTEMPT, FTD_WINDOW, RALLY_FAILED, FTD_INVALIDATED |
| `null` | NO_SIGNAL: warm-up before the first qualifying correction, data gap, insufficient data |
An FTD leaves a correction, and so does a new high: IBD resumes an uptrend without an FTD when an index closes at a new high. That state is `UPTREND_RESUMED` (`cycle.resumed_without_ftd` true, `ftd` null, no FTD event and no FTD-day low); every confirmed-phase rule applies to it, and its failure reference is the active attempt's reference low, or the lowest low of the active correction segment when no attempt is active. Tuning knob `FTD_RESUME_NEW_HIGH`, read from the environment when an index is analyzed (so a replay script can set it per run): `pre_correction_high` (default: a close above the peak the correction was measured from), `52w` (above the highest close of the previous 252 sessions; off until 252 sessions exist since the replay start), `replay_high` (above the highest close in the fetched history, which is not a true all-time high) or `off`. An invalid value warns on stderr and uses the default. The default is uncalibrated; the effective value is recorded in `cycle.parameters`. IBD sets one status
from either major index, so the combined status follows the better confirmed index (`FTD_CONFIRMED` or `UPTREND_RESUMED`; a failed event on the other index never replaces it). The resume reference `replay_high` is the highest valid close in the fetched history.
A close below the 50-session SMA puts it under pressure only after the index has closed above that SMA once since the FTD (`cycle.regained_50sma_since_ftd`), as an FTD normally comes from below it. The uptrend ends (market in correction) on 6+ active distribution days with a close below the 50-day line, even if the SMA was never regained, or on a 10% drawdown from the post-FTD peak. Secondary sources describe IBD's trigger variously (one cites the 21-day EMA); the 50-day line avoids declaring corrections on shallow pullbacks, and the threshold is unverified. Two tuning knobs, read from the environment when an index is analyzed, make the distribution correction trigger stricter (an invalid value warns on stderr and uses the default; the effective values are in `cycle.parameters`; the defaults reproduce the behavior above and are uncalibrated): `FTD_CORRECTION_DD_COUNT`, an integer from 6 to 10 (default 6), is the number of active distribution days the trigger needs; `FTD_CORRECTION_MIN_DRAWDOWN_PCT`, a number from 0 to 9.99 (default 0, meaning none), additionally requires the close to be at least that many percent below the post-confirmation peak close. The undercut (invalidation), the 10% deep-drawdown trigger and the 5-DD pressure count are unchanged. A close below the FTD-day low also puts the uptrend under pressure (warning only, never a failure); `cycle.pressure_reasons` records the cause. See `references/ftd_methodology.md` for the transition rules (uncalibrated model choices).
| State | Definition |
|-------|-----------|
| NO_SIGNAL | Warm-up (no qualifying correction since the replay start), data gap or insufficient data |
| CORRECTION | 3%+ decline with 3+ down closes, or a confirmed uptrend ended by distribution or a 10% drawdown |
| RALLY_ATTEMPT | Day 1-3 of rally from the recent pullback low |
| FTD_WINDOW | Day 4-10, waiting for a qualifying FTD |
| FTD_CONFIRMED | Valid FTD; stays until the rally low is undercut or the uptrend ends (see `market_status`) |
| UPTREND_RESUMED | A new high ended the correction without an FTD; a confirmed uptrend with no FTD event (`cycle.resumed_without_ftd`) |
| RALLY_FAILED | Rally undercut the rally low, or no FTD by Day 10 (`rally_attempt.end_reason`: `undercut` or `expired`) |
| FTD_INVALIDATED | Intraday low below the rally low of the attempt that produced the FTD |
## Quality Score (0-100)
| Score | Signal | Exposure |
|-------|--------|----------|
| 80-100 | Strong FTD | Not assessed |
| 60-79 | Moderate FTD | Not assessed |
| 40-59 | Weak FTD | Not assessed |
| <40 | Very weak FTD (unless explicitly invalidated) | Not assessed |
| 0 | No FTD, Failed/Invalidated, Unavailable: data gap, a Very weak FTD at the floor, or FTD under pressure at the floor | Not assessed |
A score of 0 alone does not mean a data gap. Read `signal`, the market state and
the quality score's `data_gap` (set only with `Unavailable: data gap`) before
interpreting it.
---
## Prerequisites
- **FMP API Key:** Required. Set `FMP_API_KEY` environment variable or pass via `--api-key` flag.
- **Python 3.9+:** With `requests` library installed.
- **API Budget:** Four logical data requests per execution; retries may add calls. Endpoint entitlement depends on the provider plan.
## Output Files
- JSON: `ftd_detector_YYYY-MM-DD_HHMMSS.json`
- Markdown: `ftd_detector_YYYY-MM-DD_HHMMSS.md`
### Data gaps (missing or invalid price bars)
A missing or non-finite close/volume (or a non-positive close) is never read as 0, and bars are never dropped. Bar fields are read through the vendored `scripts/_price_bars.py` helper.
- **JSON `data_gap`** (bool, every run, at the top level and in `market_state`): true when an index replay hit a bad bar it could not restart past (a bad close, volume or low restarts the replay after it, which needs 60 clean sessions) or a post-FTD check hit a bad bar.
- **JSON `data_quality`** (every run): per index, the window check (`window_sessions`, `bad_bars`, `bad_dates`, `latest_bad`) plus `sp500.power_trend_bad_bars` for the power-trend input (counted only when the power trend runs, 50+ bars). Each index block also carries its own `data_quality`, and `error` when the analysis failed ("Insufficient data" or "Data gap: ...").
- **Close/volume-gapped index:** `NO_SIGNAL` with `current_price` / `lookback_high` / `correction_depth_pct` set to `null`; no rally or FTD logic runs for it. With any gapped index the run's `combined_state` is reported as `NO_SIGNAL` with `data_gap: true`, meaning *state unavailable* (not an uptrend), with `ftd_index: null` and no post-FTD checks. The other index is never promoted, because the gap could be hiding the gapped index's own (possibly invalidated) FTD. Each index's own analysis stays in the JSON. The Markdown headline reads "State unavailable (data gap)".
- **Unavailable score:** if any index is gapped, or the post-FTD distribution or invalidation check has a gap, `quality_score` is `total_score: 0` (always an int, never `null`), `signal: "Unavailable: data gap"`, `exposure_range: "Not assessed"`, `data_gap: true`. Treat this as "no usable confirmation": do not increase exposure on it. A gapped distribution check keeps `distribution_count: 0` (int) with `data_gap: true`; a gapped invalidation check reports `invalidated: null`. A post-FTD gap also reports the combined state as `NO_SIGNAL` with `data_gap: true` (state unavailable), since the FTD can be neither confirmed nor invalidated.
- **Power trend:** a bad close anywhere in its input gives `power_trend: null` with a `reason`; this alone does not set `data_gap` or change the score.
- **Volume 0 is a data gap.** For ^GSPC and the selected Nasdaq instrument a zero session volume is provider missing data, so a missing, invalid or zero volume within the replayed history (or the post-FTD checks) marks a data gap. This is a behavior change from earlier versions, which read volume 0 as real.
- **One bar per trading day (#921).** Rally days are counted by bars, so the history is checked before any replay, in `scripts/session_sequence.py`. An exact duplicate of the previous bar (same date, same values) is dropped and listed in the index's `data_quality.duplicate_dates_dropped`; the Markdown data-quality line names the dropped dates. A second bar with the same date but different values, a bar dated before the previous one, or a bar dated after today in New York makes that index unavailable: `data_gap: true`, `error` and `data_quality.sequence_error` starting with "Data error:" and naming the date, and the combined state `NO_SIGNAL` as for any gapped index. The post-FTD checks use the same cleaned history.
- **Early-close volume reference.** An early-close (half-day) session and the session after it compare volume with the most recent full-length session from the vendored XNYS calendar. The FTD and post-FTD distribution JSON records this as `volume_reference` (basis `previous_full_session` plus the reference date); all other sessions keep the previous-session comparison.
## Reference Documents
### `skills/ftd-detector/references/ftd_methodology.md`
- O'Neil's FTD rules in detail
- Rally attempt mechanics and day counting
- Historical FTD examples (2020 March, 2022 October)
### `skills/ftd-detector/references/post_ftd_guide.md`
- Post-FTD distribution timing and heuristic penalties
- Power Trend definition and conditions
- Qualitative favorable/adverse context (not calibrated outcome predictors)
### When to Load References
- **First use:** Load `skills/ftd-detector/references/ftd_methodology.md` for full understanding
- **Post-FTD questions:** Load `skills/ftd-detector/references/post_ftd_guide.md`
- **Regular execution:** References not needed - script handles analysis
FTD-day-low pressure caps published quality at 59 (uncalibrated conservative heuristic); it does not erase the event or imply rally failure.
- **Lifecycle-low gap:** If only a Day 1/post-FTD low is missing, per-index and combined state are `NO_SIGNAL` with `data_gap: true`. Known prices and any already-established historical event evidence may remain visible; this does not mean the lifecycle is assessable.
### Session identity validation (issue #921)
Before replay, require real `YYYY-MM-DD` dates in ascending order. Reject a
future date (relative to the New York calendar date), an invalid date, a
conflicting same-date row, or an out-of-order new date. The index then returns
`NO_SIGNAL`, `data_gap: true`, and an `error` naming the date; the combined
signal is unavailable. Drop only exact duplicate dictionaries, preserving the
first occurrence. Record `duplicate_dates_dropped` in
per-index `data_quality`, and show the warning in the Markdown report.
Post-FTD health uses the same deduplicated session sequence for event lookup,
distribution, invalidation, and power trend. Revalidation preserves an earlier
duplicate warning without adding the same count twice.
Sibling audit: `post_ftd_monitor.py:assess_post_ftd_health` is covered by this
validation. The independent `ibd-distribution-day-monitor` consumer
(`distribution_day_tracker.py:detect_distribution_days`, `enrich_records`)
and `market-top-detector`
(`calculators/distribution_day_calculator.py:_count_distribution_days`) also
count rows positionally and remain affected by duplicate provider sessions.
Their remediation and regression tests remain open under #921; this change
does not claim full completion of that Issue. Direct calls to the low-level
post-FTD calculation helpers require validated chronological unique history;
use `assess_post_ftd_health` as the validated public entry point.
Files in this skill
- SKILL.md
- references/ftd_methodology.md
- references/post_ftd_guide.md
- requirements.txt
- scripts/_market_calendar.py
- scripts/_price_bars.py
- scripts/fmp_client.py
- scripts/ftd_detector.py
- scripts/ftd_lifecycle.py
- scripts/post_ftd_monitor.py
- scripts/rally_tracker.py
- scripts/report_generator.py
- scripts/session_sequence.py
Attribution
Related skills
View all in research →Comments
Loading comments…
Newsletter
Get the weekly list of safe new skills, and the ones we pulled.