I Clustered the Random Entries Into 5-Day Blocks. The RSI Moved.
The short version. #27 ended with a promise: the uniform placebo is too easy a null — real entries cluster on selloff days, so let the dice cluster too. I ran it: 50 seeds, each one 7 blocks of 5 consecutive days, every day RSI(14) < 40, 35 entry bars per seed, same script, same exits, same $10,000, same 4,252 bars. In our testing:
- The clustered dice lost money. The RSI didn't move — the distribution moved under it. The clustered median is −$839.01 (mean −$512.63, SD $1,429.01, only 16 of 50 positive) against the uniform median of +$851.22. The RSI (+$1,029.36) jumps from the 50th percentile of the uniform distribution to the 82nd percentile of the clustered one (+1.08 SD, outside the IQR and outside the 1-SD band). Nine of 50 clustered seeds beat it, against ten of 20 uniform seeds.
- Buying five straight days into an oversold stretch is buying the fall, not the turn. The RSI rule buys once, when RSI turns back up through 30. The clustered placebo buys five days in a row inside the stretch — the first days are still falling. Per bar in the market, the clustered median earns −$7.98 against the RSI's +$2.01 and the uniform median's +$1.71. And 35 clustered signals collapse to a median of 11 trades (range 8–13): signals 2–5 of each block fire while already in the trade and are ignored.
- The clock looks more extreme, not less. #24's clock (+$9,870.59) sits at the 100th percentile of the clustered distribution, +7.27 SD from its mean (it was +5.37 SD against the uniform null). The harder null did not shrink the clock. It also did not shrink the COVID trade: the best clustered seed (+$2,851.28) owes $2,527.14 of it to a single trade entered 2020-03-18, and all five top seeds hold a March-2020 block.
The contract: two questions, chosen before I looked
The first is #27's closing promise, word for word: "the clustered placebo — random entries drawn only from down days (RSI < 40), in 5-day blocks, 50 seeds. The uniform placebo is too easy a null: real entries cluster on selloff days, and the question is whether the clocks beat dice that are allowed to cluster too." The second is Kamal's, from #27's comments: cluster the 83 phases by how many entry dates they share and report the effective n alongside the raw n — if the top 6 collapse into essentially one draw, the "distribution" is really a handful of independent bets. This post answers both. The design was locked before I ran anything (community officer list, 2026-12-02; design file written 2026-12-04, 19:11, before the first run):
- Same script, same exits. The #22 policy-A script, entry swapped only:
longSignal = array.includes(entries, bar_index)with 35 entry bars per seed, 2×ATR stop from the entry average price, trailing stop at highest close minus 2×ATR, 100% of equity, market orders, policy A drop, 0.1% round-trip fee, $10,000 starting equity, patched PyneCore runtime. All 100 scripts compiled with zero diagnostics; each fee/no-fee pair differs in title + commission_value only. - The blocks, computed before the run. RSI(14) is Wilder's, verified against #24's baseline run: my recomputation matches its RSI column to 0.0000, and the 35 cross-ups through 30 are exactly the published 35 (one at bar 96, before the warm-up cutoff; the other 34 at bar ≥ 100). Bars ≥ 100 with RSI < 40: 409. Legal 5-day blocks — five consecutive bars, all RSI < 40: 105 possible starts. Each seed draws 7 non-overlapping blocks (re-draw on overlap),
random.Random(seed), seeds 1–50. Seed 1's blocks, in full: starts 401, 599, 1515, 3032, 3132, 3816, 4077 — 35 bars, printed in the manifest so anyone can reproduce every seed. - Same data, same comparators. 4,252 bars of S&P 500 daily, 2010-01-04 to 2026-11-27, the same file #24 used. The uniform placebo is #24's twenty seeds, reused unchanged (fee mean +$1,169.48, SD $1,621.21, median +$851.22; no-fee mean +$1,462.11, SD $1,612.99, median +$1,114.75). The RSI (+$1,029.36 fee / +$1,209.30 no-fee) and the clock (+$9,870.59 / +$10,191.03) are the published values from #24, not re-run.
- Fee on and fee off, both. Each seed lands in its matching distribution, and the no-fee run is the shape check on the fee run.
One correction to my own design, caught before the draft: the first version of the design file wrote the RSI no-fee value as +$2,530.24 and its uniform percentile as 55th. Those are #23's CSI 300 numbers. The S&P 500 numbers are +$1,209.30 and 50.0th percentile in both versions (series24/spx_summary.json). The design file carries the correction; everything below uses the S&P 500 numbers.
Probe 1: the two distributions
Closed trades only (exit Signal != 'Open'), the convention #18–#27 used. Fee-on first — the headline:
| Clustered (n = 50) | Uniform, #24 (n = 20) | |
|---|---|---|
| Mean | −$512.63 | +$1,169.48 |
| SD | $1,429.01 | $1,621.21 |
| Median | −$839.01 | +$851.22 |
| Q1 … Q3 | −$1,528.03 … +$434.68 | −$216.92 … +$2,586.68 |
| Range | −$2,609.09 … +$2,851.28 | −$983.79 … +$3,673.34 |
| Positive seeds | 16 / 50 (32%) | 14 / 20 (70%) |
| Per bar in market (median) | −$7.98 | +$1.71 |
Read it plainly: letting the dice cluster did not make them stronger. It made them $1,690 worse at the median. The uniform placebo's median seed makes money; the clustered placebo's median seed loses $839. Two-thirds of clustered seeds end negative. The no-fee picture is the same shape: clustered median −$685.87 (mean −$391.93, SD $1,439.83, range −$2,519.10 … +$2,937.17, 19 / 50 positive) against uniform +$1,114.75 (mean +$1,462.11, SD $1,612.99). The fee moves the clustered median by $153; the clustering moves it by $1,690. The fee is not the story. The clustering is — in the opposite direction from the one I expected.
Probe 2: where the RSI and the clock sit
| Distribution | Percentile | Distance from mean | Inside IQR? | Inside 1-SD band? | |
|---|---|---|---|---|---|
| RSI (+$1,029.36) | Clustered, fee | 82.0% (41 / 50 below) | +1.08 SD | no | no |
| RSI (+$1,209.30) | Clustered, no-fee | 84.0% (42 / 50 below) | +1.11 SD | no | no |
| Clock #24 (+$9,870.59) | Clustered, fee | 100% (50 / 50 below) | +7.27 SD | no | no |
| Clock #24 (+$10,191.03) | Clustered, no-fee | 100% (50 / 50 below) | +7.35 SD | no | no |
| Uniform median (+$851.22) | Clustered, fee | 80.0% (40 / 50 below) | +0.95 SD | no | yes |
The RSI did not change. The null did. Against uniform dice the RSI is dead center — 50.0th percentile, z −0.09, inside both bands. Against clustered dice it is at the 82nd percentile, outside the IQR and outside the 1-SD band, with only 9 of 50 clustered seeds beating it (8 of 50 without the fee). That is the whole post in one paragraph, and it needs the careful reading: the RSI's edge, if it has one, is not "it buys oversold stocks." The clustered placebo also buys oversold stretches — all of its entries are RSI < 40 — and it loses. The RSI's edge, if it has one, is in when inside the stretch it buys: once, on the turn back up through 30, not five days in a row on the way down.
The clock, meanwhile, got more extreme under the harder null: 100th percentile, +7.27 SD, where it was +5.37 SD against the uniform distribution. If the clock's win were an artifact of the uniform placebo being too easy, the clustered null should have pulled it back toward the middle. It pulled it further out. And the uniform median itself sits at the 80th percentile of the clustered distribution — a uniform-random entry is a good draw inside the clustered world. The two nulls do not agree with each other, which is the point of running both: "random" is not one thing, and which random you pick moves the verdict by 32 percentile points on the same strategy.
Probe 3: why the clustered dice lose — two mechanisms, both counted
First, the trade count collapses. A clustered seed fires 35 signals and takes a median of 11 trades (range 8–13). Signals 2–5 of each block arrive while the trade from signal 1 is still open, and the rule (if longSignal and not inTrade) ignores them. The RSI fires 35 signals and takes 29 closed trades. So the clustered distribution is a distribution of ~11-trade runs, not 35-trade runs, and each trade carries more weight: the median clustered seed's biggest trade is a larger share of its net, and the distribution is noisier trade-for-trade. The two distributions are not a same-trade-count comparison, and the median gap (−$839.01 vs +$851.22) mixes a trade-count effect into the clustering effect. The per-bar comparison is the cleaner one — clustered median −$7.98/bar against uniform +$1.71/bar and RSI +$2.01/bar — and it says the same thing, so the gap is not only the count. But the count is stated here so nobody reads the medians as a pure clustering effect.
Second, five straight days buys the fall. The median clustered seed (seed 36, −$871.65; the median of 50 is the average of seeds 36 and 5) took 10 trades, won 4, PF 0.443, biggest winner +$358.73 — and without that winner it would be −$1,230.38. Seed 1, printed in full above, made −$1,389.52 on 11 trades, PF 0.365. The mechanism sentence for this post: the cross-up buys the turn; the cluster buys the stretch. An RSI < 40 stretch is a market that is falling. Buying day 1 of the stretch buys the first down day; buying days 2–5 buys the continuation. The cross-up waits for RSI to turn back up through 30 — it buys the day the fall pauses. Same regime, different day, opposite sign. That is why the clustered median earns −$7.98 per bar in the market while the RSI earns +$2.01 on the same exits, the same data, the same fee.
Probe 4: Kamal's effective n — the #27 phases, clustered by shared holding time
Kamal's question, from #27's comments: cluster the 83 phases by how many entry dates they share, and report the effective n alongside the raw n. The pre-registered rule: two phases share an edge if their in-market bar sets overlap by ≥ 50% of the smaller set; connected components are the clusters. The answer is one cluster — all 83 phases connect — but that sentence overstates the collapse, and the overstatement is itself the finding, so here is the full accounting.
Adjacent phases share almost everything: phases 79 vs 80 share 95.4% of the smaller set's in-market bars; 78 vs 79 share 93.8%; the top six phases (77–82) share 74.7–95.4% pairwise. They are one bet sampled six times, as #27 said. But the pairwise distribution across all 3,403 pairs is wider: the median pair shares 26.5% of its in-market bars (Q1 14.0%, Q3 52.3%); 903 pairs (26.5%) share ≥ 50%, 257 share ≥ 80%, 97 share ≥ 90%. The graph stays connected even at an 80% threshold — one cluster — because chaining links distant phases through their neighbors, not because phase 0 and phase 82 are the same trade. So the honest statement is: the distribution's effective sample size is far smaller than 83 — the median pair of phases shares a quarter of its time in the market, and the top six share three-quarters or more — but "effective n = 1" would be the chaining talking, not the data. The percentiles in #27 are exact counts of phases, not confidence statements about the grid, and this probe is the reason that sentence was in #27's limits section. Shared entry dates between phases, for the record, are zero by construction — phases differ by one bar, so their entry days never coincide. The overlap is in holding periods, not entries.
Probe 5: the top is one event again
The best clustered seed (+$2,851.28, seed 25) owes $2,527.14 of it to a single trade entered bar 2,568 — 2020-03-18 — and exited bar 2,628; without it, +$324.14. All five top seeds (25, 27, 33, 12, 4) hold a block starting in March 2020; 29 of the 350 drawn blocks (8.3%) start that month. The clustered top is the COVID rebound, sampled five times — the same event that topped #27's phase distribution, wearing a different null. And the seeds are not 50 independent draws: only 103 distinct blocks appear in the 350 drawn (29.4%), because there are only 105 legal block starts in the whole 17 years. The clustered distribution is a distribution over which seven of 105 selloff stretches you happened to buy. One more note on the probe as designed: the design also asked for a 2008–2009 block count. That half of the probe is void — the data starts 2010-01-04, so there is no 2008–2009 in it. Zero blocks there is a data range, not a finding, and it is not reported as one.
How I checked the numbers
The checks, so anyone can repeat them:
- RSI verified before generating. My Wilder RSI(14) recomputed from SPX_daily.csv matches #24's baseline RSI column to a maximum absolute difference of 0.0000, and the cross-ups through 30 are exactly the published 35. The 105 legal block starts were enumerated from that verified series, not from the trade files.
- Seed 1, in full. Blocks start 401, 599, 1515, 3032, 3132, 3816, 4077; the 35 entry bars are 401–405, 599–603, 1515–1519, 3032–3036, 3132–3136, 3816–3820, 4077–4081. Seed 1 fee net −$1,389.52 on 11 trades, PF 0.365. The full manifest (all 50 seeds, blocks and bars) is in clustered_bars.json.
- Medians recomputed by hand. Fee: the 25th and 26th of 50 sorted nets are seeds 36 (−$871.65) and 5 (−$806.37); their average is −$839.01, matching the analyzer. RSI positions: 41 of 50 clustered fee nets below +$1,029.36 (82.0%); 42 of 50 no-fee nets below +$1,209.30 (84.0%). Z-scores: (1,029.36 − (−512.63)) / 1,429.01 = +1.08; (9,870.59 − (−512.63)) / 1,429.01 = +7.27.
- Per-bar dollars, recomputed from the raw trade files. RSI $2.01/bar fee ($1,029.36 / 511 hold bars), $2.37/bar no-fee; uniform placebo medians $1.71/bar fee and $2.29/bar no-fee, recomputed from #24's trade files (that field was not in #24's summary — this is new). Clustered per-bar medians are the medians of the per-seed per-bar values, not the median net divided by the median hold.
- The bar-96 trade. The RSI's first signal is at bar 96, before the clustered universe starts at bar 100. Its trade (entry bar 97) lost −$315.34. No counterfactual was computed — with 100%-of-equity sizing, removing one trade changes every later position size, so subtraction would not be valid. The asymmetry cuts against the RSI (its published number includes a losing trade the placebo could never draw), so the comparison is conservative, not flattering.
- The effective-n probe, recomputed. In-market sets from #27's g83 fee trade files (closed trades only); pairwise shares recomputed in supplement.py; the 80% threshold re-run gives the same single connected cluster, and the pairwise distribution above is from all 3,403 pairs.
- All 100 scripts compiled with zero diagnostics, and the design file's own correction (RSI no-fee +$1,209.30, not +$2,530.24; 50.0th percentile, not 55th) is recorded in the design file, not silently fixed.
What this test does not prove
- The clustered placebo is not a fairer null — it is a different null. Uniform sampling asks "does the entry do anything at all." Clustered sampling asks "does the entry do anything inside the regime it fishes in." The RSI's move from the 50th to the 82nd percentile is a statement about the second question, not a revision of the first. Neither distribution is "the" random baseline.
- The median gap mixes a trade-count effect. Clustered seeds take ~11 trades, uniform seeds ~31, the RSI 29. Part of the −$839 vs +$851 gap is fewer, heavier trades, not clustering alone. The per-bar comparison (−$7.98 vs +$1.71) is the cleaner read, and it agrees — but the raw medians should not be quoted as a pure clustering effect.
- Fifty seeds share 103 blocks. The seeds are not independent draws; they are 50 hands dealt from 105 blocks. The distribution's spread understates the uncertainty about the population of selloff stretches, and the top seeds' shared March-2020 block is the same event counted five times.
- One market, one window. Everything here is the S&P 500, 2010–2026, a market that rose 544%. The clustered placebo on a flat or falling market would look different, and I have not run it. The CSI 300 version is the obvious next market, not yet run.
- The exits are still untested as an edge. The clustered test says the RSI's entry timing matters given these exits. It doesn't say the exits have an edge, and the mean clustered seed is 2.5 standard errors below zero on a market that rose 544% — the drift is doing a lot of work in every number in this series, including the RSI's.
- One block length, one RSI threshold. All blocks are 5 days, all entries RSI < 40. A 3-day block or an RSI < 30 universe would draw a different distribution, and I have not run them. The exit-shuffle test is next, not a block-length sweep.
Bottom line
23's uniform placebo said the RSI entry was decoration: 50th percentile, dead center, indistinguishable from dice. #28's clustered placebo says something narrower and more interesting: against dice that are allowed to buy the same oversold stretches, in the same five-day bursts, the RSI sits at the 82nd percentile — outside the IQR, outside the 1-SD band, beaten by only 9 of 50 seeds. The entry is not decoration. But it is not "buying oversold" either: the clustered dice buy oversold too, and they lose $839 at the median. What the RSI buys is the turn — one entry, on the day RSI comes back up through 30 — and the clustered test is the first one in this series that separates the turn from the stretch. The clock survived the harder null as well: 100th percentile, +7.27 SD, further out than against the uniform dice. And the top of both distributions is still March 2020, sampled five or six times — which is why the percentiles are counts, not confidence, and why the next test has to shuffle the exits, not the entries. If the edge lives in the exits, shuffling them should kill it. If it survives that too, I will have run out of easy nulls.
Next post (#29): exit-shuffle, 50 seeds — same entries as the RSI, exits drawn at random from the observed exit distribution. The question is whether the edge lives in the exits after all.
Disclosure: I built Pine2Py (pine2py.com), the Pine Script → Python converter this series runs on. The strategy in this post is a test script, not a recommendation; nothing here is investment advice, and past backtest results don't predict anything. Free accounts get 3 conversions total; Pro is $12/month via Paddle. The runs above used the patched PyneCore runtime build provided on the site (stock PyPI PyneCore is not supported). All numbers are from local runs on 2026-12-04, in our testing: 1,909 real-world scripts compile at 99.7% and fully translate at 98.4%.

