# Double 7s (Connors and Alvarez) on SPY, daily closes - specification (RIP Backtest protocol v1.0 plus the 8 Oct 2026 rules)

**Specification written and frozen 2026-11-20 (approved by the owner the same day: "aprob"). It is draft 1, unchanged, with one version (D7); the optional D7-NF was not picked.** It is written before any 7-day low or high, signal or trade of this rule is computed on SPY or on any other market. The only computation for this test is the data check of 2026-11-20 (below), which computes no signal. Once frozen, a change of a rule is a separate test; bugs may be fixed and are logged.

## Why this test, and what was looked at before
- **Chosen by the owner** on 2026-11-20, after the Turtle Soup ES result, from rules with good published evidence. It is the closest relative of the only daily rule on the site that passed every gate (RSI(2) on SPY). It was picked because it is a likely candidate. That changes nothing in the rules, the gates or the control; it makes a pass weaker evidence, and the article says so.
- **The idea.** Larry Connors and Cesar Alvarez, *Short Term Trading Strategies That Work* (2008), chapter 10, "Double 7's Strategy", for indices and index ETFs, SPY as the example. As the pages we read summarise it:
  1. SPY is above its 200-day moving average;
  2. if SPY closes at a 7-day low, buy;
  3. if SPY closes at a 7-day high, sell the long position.
  No stop.
- **What we could and could not check (2026-11-20).** We did not have the book. Pages read:
  - Market Analysis blog (13 March 2012): rules 1 to 3 above, for "a number of ETFs"; no definition of the 7-day window; no fill time. It relays the book's SPY figures (see the next point).
  - The Robust Trader (updated 10 February 2024): close above the 200-day average, buy at the close at a 7-day closing low, sell at the close at a 7-day closing high, no stops.
  - StrategyQuant (16 September 2026): "equal to or lower than the lowest Close of the last seven bars, including the current bar", the mirror for the exit, close above the 200-day simple average at entry, orders on the bar's close, no stop, target or time exit, long only.
  - Backtested Strategies (6 May 2026): the 200-day average is "an entry filter only" and does not force an exit; long only; its exact rules are paywalled.
  - StatOasis (December 2024, updated September 2026): today's close the lowest of the last seven, the 200-day filter at entry, no stop; its own tests fill at the next open and say Connors buys the close.
  - TradingView script "Double 7's Strategy" (Tomazetti, 7 July 2019): "closes below the closing of the last 7 days", no stop.
  - Several of these pages show backtests of their own. Per the site's practice (owner, 2026-11-18), the article neither cites nor compares with other sites' tests.
- **The claim being checked.** The only figures attributed to the book are relayed by the 2012 blog, not checked by us: SPY 1993-2008, 153 trades, 80.4% winners, +0.85% a trade on average. The article may quote them only with that label.
- **Three layers, kept apart here and in the article:** what the rule says (rules 1 to 3, on which every page agrees); what we fix where the summaries are vague (next section); what we add (the costs, the periods, the control, the gates).

## What we fix where the summaries are vague (each fixed once, here)
1. **The 7-day window is today and the 6 trading days before it** (StrategyQuant, StatOasis). The TradingView wording ("below the closing of the last 7 days") could also mean today against the 7 closes before it, an 8-day window; not used.
2. **"At a 7-day low" means at or below:** today's close is lower than or equal to each of the 6 closes before it (StrategyQuant's "equal to or lower"). Equal closes are rare: 62 of 8,488 closes (0.73%) equal the close before them.
3. **The exit mirrors it:** today's close is higher than or equal to each of the 6 closes before it. The window can reach back before the entry day.
4. **The 200-day filter is the close strictly above its 200-day simple average of closes, checked at entry only.** A trade stays open if SPY falls below its average (every page that says anything says this).
5. **Fills at the close of the signal day,** for the entry and the exit (Connors' convention, The Robust Trader, StrategyQuant). Fills at the next day's open are reported, not gated.
6. **Long only.** The published summaries give no short side; none is tested.
7. **One position at a time.** No adding while in a trade. After an exit at the close of day k, the next entry is considered from day k + 1.
8. As in the RSI(2) SPY test: indicators on the raw closes, trades on total returns (dividends), signals from the 250th day, a trade open at the end of the data closed at the last close.

## Looked at before on this site (disclosed)
- **The dip-buying family, daily index rules:**
  - RSI(2) on SPY (`rsy_spec.md`, 6 Nov 2026): below-10 version **Survivor 6 of 6**, below-5 version 5 of 6 (trade count);
  - RSI(2) on QQQ (`rqq_spec.md`): 3 of 6 (below 10) and 5 of 6 (below 5);
  - RSI(2) on the DAX (`rdx_spec.md`): 3 of 6 for both.
  - Also, all Buried: RSI(2) on ES 60-minute bars with our extra rules; RSI(2) on four FX pairs; the IBS daily reversal on NQ.
- **The family has well over four versions on the site, so the development bar is t >= 2.5.** That is a stricter bar for a crowded family, not a full correction for multiple testing; the article says so.
- **The same SPY file** in six tests (SMA 200, Accumulation/Distribution, turn of the month, pre-holiday, pre-FOMC, RSI(2)). The holdout below is already used, and the RSI(2) SPY trades of 2016-2026 are known.
- **Not independent of RSI(2) SPY.** A close at a 7-day low above the 200-day average is often also a day with RSI(2) below 10. Many entry days will be shared, so a pass here would mostly repeat the RSI(2) result, not add independent evidence. The shared days are reported.
- **No 7-day closing low or high has been computed on SPY or any other market for this site.**

## Why it might not work (written before any result)
1. **The control is hard to beat.** On SPY, random dips in an uptrend made +0.32% a trade in the RSI(2) test (median of the control). The 7-day low must pick clearly better dips than that.
2. **The exit can take weeks.** A 7-day closing high needs a full recovery of the last six closes. With no stop, and no exit when SPY falls below its 200-day average, a dip can become a crash.
3. **Public since 2008,** and the book's own sample ends there; an edge can fade once it is published.
4. **The holdout is already used,** including by the RSI(2) SPY test.

## Instrument and data
- **SPY**, daily bars 1993-01-29 to 2026-10-20 with 136 dividends, the files of the RSI(2) SPY test: `spy_daily.csv` (sha256 8de2b35662134fe5...), `spy_dividends.csv` (f6a7857257bbd23c...), `dtb3_fred_raw.csv` (0ba63bf126e01aa6...). Loader: `sma200_lib.loadData`. The later days stay unseen, as for the RSI(2) tests.
- **Indicators on the raw daily closes. Returns are total returns:** a dividend is reinvested at its ex-date close, so a trade bought at the close of day j and sold at the close of day k grows by the product of (close[i] + dividend[i]) / close[i-1] for i = j+1 .. k.
- **The data check of 2026-11-20 (`d7_datacheck.js`, output `d7_out/d7_datacheck.txt`)** computed no 7-day low or high, signal or trade:
  - the three files are byte-identical to those of the RSI(2) SPY test;
  - 8,489 days, 1993-01-29 to 2026-10-20, 136 dividends, all on trading days;
  - no date out of order, repeated or on a weekend; no row with the high or low outside the open and close;
  - one gap of more than 5 calendar days: 2001-09-10 to 2001-09-17 (the exchange closure after 11 September);
  - total return with dividends reinvested x31.994, against Yahoo's adjusted close x31.977;
  - 62 flat closes (0.73%).

## Rules
- **SMA(200):** the plain average of the last 200 closes, the day itself included.
- **LOW7 and HIGH7 of day i:** the lowest and the highest of the closes of days i-6 to i.
- **Entry:** at the **close** of day i, if no position is open, i is the 250th day of the file or later (from 1994-01-24), **close[i] > SMA200[i]**, and **close[i] <= each of close[i-6] .. close[i-1]** (so close[i] = LOW7[i]).
- **Exit:** at the **close** of the first later day k with **close[k] >= each of close[k-6] .. close[k-1]** (so close[k] = HIGH7[k]). The 200-day average plays no part in the exit.
- **No stop, no target, no time limit.** The worst open loss of every trade is reported. A position open at the end of the data closes at the last close, flagged.

## Versions
| ID | Rule | Role |
|---|---|---|
| D7 | as above | the published rule |

**One version is proposed.** An optional second version, only if the owner picks it before the freeze: **D7-NF**, the same rule **without the 200-day filter** (it asks whether the filter matters); its control would be random entries on any dip (close below its 5-day average), with no trend condition. Every extra version is one more try in a crowded family.

## Costs
- **0.04% of the price per round trip**, as in the other SPY tests (our model); 0.10% shown as a scenario. The verdict is that of 0.04%.

## Results, periods, gates, control
- **Unit:** net % per trade.
- **Periods (by entry date), as in the RSI(2) SPY test:** development 1993 .. 2005 (signals from 1994-01-24); validation 2006 .. 2015; holdout 2016 .. 2026-10-20 (**already used**, see above).
- **Expected number of trades (for planning only; not published):** about 8 to 12 a year, so roughly 100 / 90 / 100 in the three periods. The guess comes from the relayed book figure (153 trades in about 15 years).
- **Six gates per version:**
  1. validation profit factor >= 1.2;
  2. at least 50 trades in each period;
  3. development **t >= 2.5**;
  4. above the 95th percentile of 500 runs of the matched control;
  5. positive without the 10 best trades;
  6. holdout net positive (flagged used).

  Fewer than 30 trades: Inconclusive.
- **Matched control (as in the RSI(2) SPY test): random dips in an uptrend.**
  - Random entries on days with the close above its SMA(200) and **below its SMA(5)**, while flat.
  - Each such day is entered with one probability, calibrated so that the mean number of trades matches the real version.
  - The same exit (the first later close at or above the 6 closes before it), the same costs and fills. 500 runs, seeds 1000 + run. Statistic: average net % per trade.
  - A close at or below the 6 closes before it is at or below its 5-day average, so the D7 entry days lie inside this pool, apart from the case of five equal closes.
  - It asks whether a 7-day closing low picks better dips than any dip in an uptrend, with the same exit.
  - With the D7-NF option only: the same control without the 200-day condition.

## Also reported (descriptive, after the gates; nothing here can change a rule or the verdict)
- Win rate with its Wilson interval; holding days (median, longest); time in the market; the worst open loss; by year and by period; without the 10 and the 20 best trades.
- The whole strategy with T-bill interest while out, against buy-and-hold (growth, yearly return, largest drawdown at daily closes with open losses included, volatility), and the crashes.
- The 0.10% cost; **fills at the next day's open** for entries and exits.
- **D7 next to RSI(2) SPY (below 10):** shared entry days; D7 trades that overlap an RSI(2) trade; the two side by side by period.
- Trades still open on a day SPY closed below its 200-day average (the filter is at entry only).

## Engine and self-test (before the run)
- **`d7_lib.js`**, the engine: the SPY loader and the trade arithmetic of `rsy_lib.js` (total-return growth, costs, next-open fills, equity with T-bills), with its own 7-day windows, entry, exit and control.
- **`d7_ref.js`**, a separate re-implementation written from this file, not from the engine: its own CSV reading, windows from slices, a day-by-day state machine and its own trade arithmetic. Written by the same author (an AI, Claude), not by an independent person or agent; that is stated.
- **`d7_selftest.js`** must pass before any result is printed:
  1. **Hand-worked series:** LOW7 and HIGH7; an entry at a close equal to the lowest of the 6 before it (a tie) and none one cent above; none below the 200-day average; an open trade kept when the close falls below the 200-day average; the exit at a tie with the highest; the exit window reaching back before the entry; no entry on the exit day; a dividend inside a trade; the end of the data; the costs; next-open fills; the equity with T-bills.
  2. The control's pool (only days above SMA(200) and below SMA(5), only while flat) and its calibration.
  3. **Engine = re-implementation,** indicators day by day and trades one by one on the real data.
  4. A control run whose entries are the real ones reproduces the real trades.
  5. **Mutations** that check 3 must detect: a 6-day window; an 8-day window; an exit window of 5 days; the 200-day filter also at the exit; fills at the next open.
- **`d7_run.js`** refuses to run unless this file's hash matches the frozen one and the self-test passed on the current code. One run; outputs in `research/d7_out/`.

## Before the article
- Results go to the owner first, in Romanian, with every gate, whatever they are.
- An article only if the owner asks for it, at the site's pace; deploys only with the owner's explicit agreement.
- **Working title:** "Double 7s Strategy on SPY: 33-Year Backtest of Connors' Rules". It links to the RSI(2) SPY post and the other RSI(2) posts.
- The article does not cite or compare with other sites' tests. It says the book text could not be checked and lists the fixes above.

## Reading the result
- "Buried" or "Inconclusive" mean a statistically convincing edge was not shown, not proof that none exists.
- A "Survivor" here would be one ETF, one data source, a used holdout, and a rule that shares many entry days with a result already published. It would not be independent confirmation of the RSI(2) result; only new data can give that.

### Run log
- 2026-11-20: the owner chose the test (Double 7s on SPY daily). Sources read (Market Analysis blog 2012, The Robust Trader 2024, StrategyQuant 2026, Backtested Strategies 2026, StatOasis 2024/2026, TradingView 2019). The book itself was not available.
- 2026-11-20: the data check (`d7_datacheck.js`, `d7_out/d7_datacheck.txt`); no 7-day low or high, signal or trade computed.
- 2026-11-20: draft 1 written.
- 2026-11-20: **frozen** (owner: "aprob", relayed by the session that runs the site), draft 1 unchanged, one version (D7; the optional D7-NF was not picked). sha256 of this file above the "### Run log" heading: c0ff8e8eb01ac3c088fbbff0575fcd304d6e7ea8160a39fe3c62636f4fe01693.
- 2026-11-20, before the run: `d7_lib.js` (engine; trade arithmetic, costs, next-open fills and equity from `rsy_lib.js`), `d7_ref.js` (separate re-implementation: own CSV reading, windows from slices, its own state machine and trade arithmetic) and `d7_selftest.js` written. The self-test **PASSED 26 of 26 on its first run** (`d7_out/d7_selftest.txt`): 13 hand-worked checks (the averages; LOW7 and HIGH7 with ties; one cent above the low and below the high; no entry below the average; a trade kept open below it; the exit window reaching back before the entry; no entry on the exit day; a dividend; the cost; the end of the data; next-open fills; the equity with T-bills); 8 real-data checks (the reference reads the same file; indicators equal on every day; engine = re-implementation trade by trade; entries and exits only where the rule allows; the control with the real entries reproduces the real trades; every entry day inside the control pool (0 outside); the control pool; its calibration); 5 mutations detected. Counts only: D7 326 trades. It was run again, unchanged, after `d7_run.js` was written (the run requires a self-test newer than its own file): PASSED.
- 2026-11-20, the run (`node d7_run.js`, once, outputs in `d7_out/`). **D7 Survivor, 6 of 6:** 326 trades (115 / 100 / 111), +0.710% a trade net (+0.750% before costs), 78.8% winners; development t 5.12; validation PF 2.19; holdout +66.8% PF 2.16 (already used); without the 10 best +186.9%; **the control at the 95.20th percentile, at the edge of the gate** (random dips in an uptrend with the same exit: median +0.610%, 95th percentile +0.709%; 24 of the 500 runs averaged as much or more). With 500 runs, the percentile itself is uncertain by about one point; this is a reading, and the verdict stands as the protocol gives it. Descriptive: next-open fills +0.663% a trade; at a 0.10% cost +0.650%; the whole strategy with T-bills x16.65 (9.0% a year, max drawdown -14.1%, invested 29.9% of days) against buy-and-hold x29.06 (10.8% a year, -55.2%); worst open loss -14.04% (entered 2011-07-27); 43 trades were still open on a day SPY closed below its 200-day average (average -1.43%); 114 of the 326 entry days are RSI(2) SPY below-10 entry days, and 214 of the 326 trades overlap an RSI(2) trade. Nothing was rerun or changed.
- 2026-11-20: published as /posts/double-7s-strategy-spy/ on 20 Nov 2026 (the owner asked for the article on 2026-11-20: "Da, scrie-l"; deployed with the owner's explicit agreement). The article cites no other site's test of the rule; the book's figures are quoted once, labelled as relayed by a 2012 blog summary and unchecked. Article notes, descriptive only: the results before and after 2008, on shared and other entry days, the crash trade counts, the longest holds and the control histogram were computed from the run's files by `build_d7_post.js` (the run's own files are unchanged).
