Skip to content

Double-bottom detector (experimental) and a --patterns switch for the replay - #127

Merged
yanivil merged 1 commit into
mainfrom
feat/double-bottom
Sep 17, 2026
Merged

yanivil merged 1 commit into
mainfrom
feat/double-bottom

Conversation

@yanivil

@yanivil yanivil commented Sep 17, 2026

Copy link
Copy Markdown
Owner

Summary

The first candidate pattern since the cup went watch-only: a double-bottom detector, built on the inverse head and shoulders template, kept out of the nightly scan until it passes the replay gate (#126).

Detector detect_double_bottom

  • Two consecutive swing lows within 3 % of each other, either one the lower (the shake-out is allowed); the rally peak strictly between them at least 10 % and 2 ATR above the higher low; the peak not too close to either low in time; a prior decline of one height into the first low or SMA50 below SMA200.
  • A daily close above the peak is the trigger (constant, through evaluate_breakout, floor the second low); stop under the second low, the pattern's invalidation, like the H&S right shoulder; target one height (peak minus the lower low) above the entry; the H&S's age lag (the second low is a swing low, visible five bars later), volume rule, risk cap and listing limit.
  • Bulkowski's 10 % rise rule is what keeps noise out: with the ATR depth rule alone 43 of 200 random walks show a W; with it, five (the inverse H&S: two). A test pins that rate.
  • With equal lows the reward is one height and the risk slightly more, so the reward:risk sits just under 1 and tuned's floor keeps only the higher-second-low form; the replay measures both.

Plumbing

  • PATTERN_DETECTORS holds every detector by name; ACTIVE_PATTERNS is what the nightly scan runs (unchanged: cup, H&S, Wolfe) and what the report and meta iterate. The double bottom is registered but not active.
  • tools/backtest.py --patterns cup,ihs,wolfe,db (or the full names) replays any subset; the workflow gains the patterns input; the JSON records the patterns run.

Tests (164): levels recomputed from the notes and the documented formulas, single-rule mutations rejected (lows too far apart, rally under 10 %, lows too close in time, nothing to reverse), isolation (not in DETECTORS, the other fixtures are not W's and the W is not an H&S or a cup), the controls and the 200-random-walk rate, and --patterns parsing and selection end to end.

Docs: wiki 02 (the pattern's section, marked experimental), wiki 03 (its constants, the --patterns switch), wiki 04, README (the pattern table), changelog.

Replay: the eleven yearly point-in-time runs are dispatched from this branch with patterns=cup,ihs,wolfe,db, plus a second set with MIN_REWARD_RISK=None; the result and the decision go on #126. Merging this PR changes nothing in the nightly scan.

Test plan

🤖 Generated with Claude Code

…or the replay

detect_double_bottom: two consecutive swing lows within 3 %, the rally
between them at least 10 % and 2 ATR above the higher low, a prior decline
or SMA50 < SMA200, a close above the peak as the trigger, stop under the
second low, target one height above the entry, and the H&S's age lag,
volume, risk and listing limits. PATTERN_DETECTORS holds every detector,
ACTIVE_PATTERNS what the nightly scan runs; the report and meta iterate the
active set. The backtest gains --patterns (cup, ihs, wolfe, db) and the
workflow a patterns input. Fixture, tests (164: levels from the notes,
single-rule mutations, isolation, a 200-random-walk false-positive rate),
wiki 02, 03 and 04, README, changelog.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@yanivil
yanivil merged commit 5860ff5 into main Sep 17, 2026
28 of 29 checks passed
@yanivil
yanivil deleted the feat/double-bottom branch September 17, 2026 19:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant