ftd-detector
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).
How do I install this agent skill?
npx skills add https://github.com/tradermonty/claude-trading-skills --skill ftd-detectorIs this agent skill safe to install?
- Gen Agent Trust Hubpass
The skill detects stock market bottom signals by running a Python analysis script and fetching data from the Financial Modeling Prep API. It can execute local code and perform network requests to retrieve financial information, so verify the data source requirements before providing an API key.
- Socketpass
No alerts
- Snykpass
Risk: LOW · No issues
- Runlayerwarn
5/12 files flagged
- ZeroLeakspass
Score: 93/100 · 2 sections analyzed
What does this agent skill do?
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 QQQonly 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_scoreis an uncalibrated technical heuristic, not success probability.exposure_rangeisNot assessedin 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:
python3 skills/ftd-detector/scripts/ftd_detector.py --api-key $FMP_API_KEY
The script will:
- Fetch S&P 500 (^GSPC) and Nasdaq Composite (^IXIC) historical data (500 trading sessions; the whole history is replayed) from FMP API
- Fetch current quotes for both indices
- Run dual-index state machine (correction → rally → FTD detection)
- Assess post-FTD health (distribution days, invalidation, power trend)
- Calculate quality score (0-100)
- 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_KEYenvironment variable or pass via--api-keyflag. - Python 3.9+: With
requestslibrary 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 inmarket_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) plussp500.power_trend_bad_barsfor the power-trend input (counted only when the power trend runs, 50+ bars). Each index block also carries its owndata_quality, anderrorwhen the analysis failed ("Insufficient data" or "Data gap: ..."). - Close/volume-gapped index:
NO_SIGNALwithcurrent_price/lookback_high/correction_depth_pctset tonull; no rally or FTD logic runs for it. With any gapped index the run'scombined_stateis reported asNO_SIGNALwithdata_gap: true, meaning state unavailable (not an uptrend), withftd_index: nulland 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_scoreistotal_score: 0(always an int, nevernull),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 keepsdistribution_count: 0(int) withdata_gap: true; a gapped invalidation check reportsinvalidated: null. A post-FTD gap also reports the combined state asNO_SIGNALwithdata_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: nullwith areason; this alone does not setdata_gapor 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.
- 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(basisprevious_full_sessionplus 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.mdfor 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_SIGNALwithdata_gap: true. Known prices and any already-established historical event evidence may remain visible; this does not mean the lifecycle is assessable.
How can the creator link this skill?
Add the canonical catalog link to the repository README so users can inspect current installs and available audits. The publishing guide covers the complete discovery path.
<a href="https://skillzs.dev/skills/tradermonty/claude-trading-skills/ftd-detector">View ftd-detector on skillZs</a>