# Accumulation/Distribution (A/D) on Bitcoin (BTCUSDT), 4-hour bars - specification (RIP Backtest protocol v1.0 plus the 8 Oct 2026 rules)

Specification written and **frozen 2026-10-22 (approved by the owner the same day, draft 1 unchanged)**. No A/D value, signal or trade of this test has been computed. Once frozen, any change of a rule is documented and treated as a separate test; bugs may be fixed.

## Why this test, and what was looked at before
- **Chosen by the owner** on 2026-10-22 ("Accumulation/Distribution Indicator (A/D) ce zici?"; market: "bitcoin 4h", over the alternative of SPY daily).
- **The idea:** Marc Chaikin's Accumulation/Distribution line adds, bar after bar, the volume weighted by where the bar closed inside its range. A rising line is read as buying (accumulation), a falling one as selling (distribution); the most taught signal is a **divergence** between the A/D line and the price, followed by crosses of the line with its average and the **Chaikin oscillator** (the difference of two averages of the line). We fix three common readings and try no others after the result.
- **Why Bitcoin:** A/D needs real volume. Our gold and forex files carry only tick counts; the Binance file carries the traded volume of every minute.
- **Looked at before on Bitcoin (disclosed):** Turtle trading (daily), intraday trend pullback (15-minute), noise area breakout, CME gap fill, all buried; and **Heikin Ashi on these same 4-hour bars** (2026-10-21), buried at 5 of 6 gates and now in a forward test. No A/D value has been computed on the site.

## Data
- **Bitcoin:** the Binance BTCUSDT spot 1-minute file of the earlier Bitcoin tests (`BTCUSDT_1min.csv`, 2017-08-17 to 2026-09-30 23:59 UTC), UTC clock, **volume in BTC** (the base asset) as published by Binance. One exchange's volume, not the whole market's; stated in the article.
- **4-hour bars** exactly as in the Heikin Ashi test: 00:00-04:00 ... 20:00-24:00 UTC, every day; open/high/low/close from the minutes, volume = the sum of the minutes' volumes; a slot with fewer than 120 minutes is **not used** (no A/D step, no signal).

## The indicator
- **Money flow multiplier** = ((close - low) - (high - close)) / (high - low), 0 if high = low. **Money flow volume** = multiplier x volume. **A/D** = the running sum of money flow volume over the used bars, from the first bar of the file.
- **Chaikin oscillator** = EMA(3) of A/D - EMA(10) of A/D (alpha = 2 / (n + 1), seeded with the first value). **A/D average** = SMA(20) of A/D.
- Every signal uses differences of the line, so its arbitrary starting level has no effect. The first 30 days only warm up the averages (no trade before 2017-10-01, as in the Heikin Ashi test).

## Rules (signals on a completed 4-hour bar, executed at the open of the first minute of the next slot; one position at a time)
- **AD-DIV (divergence):** a **swing low** is a used bar whose low is strictly below the lows of the 5 used bars before and after it; it is known at the close of the 5th bar after it. When a new swing low is confirmed, compare it with the previous swing low if that one is at most 60 bars (10 days) earlier: **bullish divergence** if the new low is lower in price but its A/D value is higher -> **buy**. **Bearish divergence** on swing highs (higher high, lower A/D) -> **sell short**. Stop at the new swing's extreme; target 2R (R = entry to stop); a trade still open after 30 bars (5 days) closes at the open of the next slot. Stop and target tested on 1-minute bars (stop first; a gapped minute fills at its open). Signals while a trade is open are ignored. No trade if the entry is already beyond the stop.
- **AD-MA (line and its average):** long when A/D crosses above its 20-bar SMA, short when it crosses below; always in the market after the first cross (each cross reverses).
- **AD-CHO (Chaikin oscillator):** long when the oscillator crosses above zero, short when it crosses below; always in the market after the first cross.
- A cross needs the earlier bar on the other side or at the line (<= then >, >= then <). A position open at the end of the data closes at the last minute's close.

## Costs
- **0.05% of the price on every fill** (about 0.1% a round trip; a reversal pays two), the Binance perpetual taker fee, as in our other Bitcoin tests, so that shorts are possible.
- **Funding sensitivity (reported, not gated):** 10% a year of the entry price per day held, longs and shorts alike. Results in % of the entry price per trade.

## Periods, gates, control
- **Periods (by entry date):** development 2017-10-01 to 2021-06-30; validation 2021-07-01 to 2023-12-31; holdout 2024-01-01 to 2026-09-30 (**already used** by five earlier Bitcoin tests).
- **Six gates per variant** (net % per trade): validation profit factor >= 1.2; at least 50 trades in each period; development **t >= 2.0** (three variants of an indicator not tested before on the site); above the 95th percentile of 500 runs of the matched control; positive without the 10 best trades; holdout net positive (flagged used). Fewer than 30 trades: Inconclusive.
- **Matched control (shifted holdings):** each variant's real position series (long, short or flat on every 4-hour slot) shifted as a whole by one random circular offset of whole days (at least 5%; seeds 1000 + run, 500 runs), traded on the real prices at slot opens with the same costs; it keeps the number of trades, holding times and long/short mix and breaks only the timing. For AD-DIV the shifted trades exit at the shifted slot of their real exit (their stops and targets are not re-checked). Statistic: average net % per trade.
- **Rule 3:** recomputed without trades open over a known data gap of at least 60 minutes.
- **Also reported:** win rate with its Wilson interval; holding time; long and short; by year; exits by reason (AD-DIV); the number of divergences found; the result against buy and hold over the same span (descriptive).

## Engine and self-test (before the run)
New engine `ad_lib.js`, independent re-implementation `ad_ref.js`, `ad_selftest.js` that must pass before any result is printed: the multiplier, the running sum, the averages and the oscillator against a hand calculation (including high = low and a short slot); swing confirmation 5 bars later; a bullish and a bearish divergence and a too-old previous swing; stop, target, the 30-bar exit and a gapped stop; crosses and reversals; the end of the data; the reference matched trade by trade on the real data for all three variants; the control at offset 0 keeping the real trades' slots and directions.

## Before the article
Results go to the owner first. One article, published only with the owner's agreement. Working title for search: "Accumulation/Distribution Indicator Strategy: Backtested on Bitcoin".

## Reading the result
"Buried" or "Inconclusive" mean a statistically convincing edge was not demonstrated; neither is proof that none exists. One market, one exchange's volume, one timeframe, three readings of an indicator with many uses.
