# Stochastic + RSI + MACD strategy on EUR/USD (15-minute, 30-minute and 1-hour bars) - specification (RIP Backtest protocol v1.0 plus the 8 Oct 2026 rules)

Specification written and **frozen 2026-10-14 (approved by the owner the same day, draft 1 unchanged)**, before any indicator value, signal or trade of this test was 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-14: the YouTube video "Most Effective Stochastic + RSI + MACD Trading Strategy (Proven 100x)" (channel Data Trader, about 814,000 views, watched through its transcript on 14 Oct 2026). The video backtests 100 trades on EUR/USD 30-minute bars and reports a 56% win rate; it recommends 15-minute to 1-hour charts. Timeframes chosen by the owner the same day: **15-minute, 30-minute and 1-hour bars**; variants: the rule as shown and the video's own "optimisation" (a stop capped at 0.15%), long and short.
- Earlier tests on this EUR/USD file: the FX study (which includes a MACD crossover and RSI(2)), the 1-hour golden cross, the Fibonacci 61.8% pullback and the Turtle rules. No Stochastic number, and no combination of the three indicators, was looked at.

## Instrument and data
- **EUR/USD** spot, the 1-minute bid history of the IC Markets MetaTrader 4 demo server, 2004-01-01 to 2026-09-28 15:46 New York, as read by the Turtle EUR/USD test (`fb_clock.loadEur({ fix: false })`).
- **Bars:** 15-, 30- and 60-minute bars on the New York clock, close time = bar time, built from the minutes that exist (`gh_lib.barsOf`). EUR/USD trades around the clock, so bars run through the night; positions are held over nights and weekends.
- **Clock:** the file's labels are an hour early in many weeks of 2004-2014 (clock audit). Bars here are continuous and cut on whole and half hours, so a shifted label moves whole bars without changing their contents, and nothing in the rule depends on the time of day. Stated in the article.
- **Holes (rule 3):** `data_holes_eur.json`; trades open across a suspect or unclear gap are counted, and every gate and verdict is recomputed without them.

## Indicators (the video's settings)
- **Stochastic (14, 3, 3):** raw %K = 100 x (close - lowest low of 14 bars) / (highest high - lowest low) (50 when the range is zero); **%K** = 3-bar simple average of the raw %K; **%D** = 3-bar simple average of %K. Oversold below 20, overbought above 80.
- **RSI(14)**, Wilder's method (seeded with the simple averages of the first 14 changes). Trend filter at 50.
- **MACD (12, 26, 9):** EMA(12) - EMA(26) of the closes, signal line EMA(9) of the MACD; EMAs seeded with the simple average of their first values.

## Rules (as in the video, fixed where it is vague)
- **Long setup:** armed at the close of a bar where **both %K and %D are below 20**; disarmed when **either %K or %D goes above 80**.
- **Long signal** at the close of bar k while the long setup is armed: **the MACD line crosses above the signal line** (MACD[k] > signal[k] and MACD[k-1] <= signal[k-1]) **and RSI[k] > 50**. A cross with RSI at or below 50 is not a signal and the setup stays armed. A signal uses up the setup (a new one needs a new oversold reading); a signal that comes while a position is open is missed (the video: one trade at a time, missed entries are fine).
- **Short:** the mirror: armed when both lines are above 80, disarmed when either goes below 20; MACD crosses below the signal line with RSI below 50.
- **Entry** at the open of the first 1-minute bar after the signal bar.
- **Stop (variant A, as shown):** one point (0.00001) beyond the **nearest swing low** (shorts: swing high): the most recent swing confirmed by the close of the signal bar whose low is below the entry signal bar's close. Swings are the fractals of the Fibonacci test: a bar whose low is strictly below the lows of the two bars before and after it, confirmed two bars later. No such swing in the last 200 bars: no trade. **Variant B (the video's optimisation):** the same, but the stop is never more than **0.15% of the entry price** away.
- **Target:** 1.5 times the stop distance from the entry. The stop and the target are checked on every 1-minute bar after the entry minute (in the entry minute only the stop); if one minute touches both, the stop counts; a level gapped through fills at the minute's open. No other exit: no time limit, held over weekends. A position open at the end of the data is closed at the last close and flagged.
- **Six variants:** **SM-M15-A, SM-M15-B, SM-M30-A, SM-M30-B, SM-H1-A, SM-H1-B**, all long and short. **R** = the stop distance at entry; results in R.
- The video sizes trades at 2% of the account with leverage; we report one unit and results in R, which is the same thing without compounding.

## Costs
- **About 1 pip per round trip** (0.15 pip on every fill plus 0.7 pip commission), the cost model of every EUR/USD test on the site.
- **Financing scenarios** (the verdict uses the baseline): A, 2% a year of the entry price per calendar day held, longs and shorts alike; B, today's IC Markets EUR/USD swap as recorded for the Turtle EUR/USD test (long -7.99, short +1.31 points per lot per night, Wednesday counting three, rollover at 17:00 New York): not a historical rate.

## Periods, gates, control
- **Periods (by entry date):** development 2004 .. 2012; validation 2013 .. 2019; holdout 2020 .. 2026-09-28 (**already used** by the earlier EUR/USD tests).
- **Six gates per variant:** validation profit factor >= 1.2; at least 50 trades in each period; development **t >= 2.5** (six variants; the protocol's bar above four); 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 (moved entries):** every real entry moved, all together, by one random circular offset of at least 5% of the days, to the same time of day on the new day, same direction, the same stop distance in price and the 1.5R target, one position at a time, same costs. 500 runs, seeds 1000 + run. Statistic: the average net R per trade.
- **The video's claim, checked separately:** the win rate of each variant with its 95% interval, against the 40% needed to break even before costs with a 1.5R target, and the 56% reported in the video.

## Engine and self-test (before the run)
A new engine (`sm_lib.js`) and a self-test that must pass before any result is printed:
1. Hand-worked cases: the Stochastic, RSI and MACD on short series; arming, disarming and using up a setup; a MACD cross with RSI below 50 (no signal, still armed); a signal while a position is open (missed); the nearest swing low and the 200-bar limit; the 0.15% cap; entry, stop, target, a minute touching both, gaps; costs and R; the financing scenarios.
2. The indicators against a naive recomputation on the real data.
3. An **independent re-implementation** matched trade by trade for all six variants on the real data.
4. The control at offset 0 reproduces the real trades.

## Before the article
Results go to the owner first: all six variants, every gate, win rates against the video's 56%, long and short separately, by year, how trades ended, holding time, the cost per trade in R, the financing scenarios, the hole check. One article (EUR/USD, three timeframes), published only with the owner's agreement.

## Reading the result
"Buried" or "Inconclusive" mean a statistically convincing edge was not demonstrated; neither is proof that none exists. One market, the video's settings, our reading of its vague points (stated above).
