# MACD + RSI crossover with an EMA 200 trend filter on NQ, 5-minute bars - specification (RIP Backtest protocol v1.0 plus the 8 Oct 2026 rules)

Specification written and **frozen 2026-10-26 (approved by the owner the same day, draft 1 unchanged: "Da, îngheață specificația MACD + RSI + EMA 200 pe NQ așa cum e")**. Once frozen, any change of a rule is documented and treated as a separate test; bugs may be fixed. No indicator value, signal or trade of this test has been computed.

## Why this test, where the rules come from, and what was looked at before
- **Chosen by the owner** on 2026-10-26 ("Da, scrie specificația MACD + RSI + EMA 200 pe NQ, 5 minute"), from an article idea he pasted: one of the most viewed kinds of YouTube tutorial combines classic indicators into a "simple" day-trading or scalping strategy, often sold with a claimed win rate of about 80%. **The template:** a large exponential average (EMA 200) on the 15-minute or 1-hour chart gives the trend; on the 5-minute chart, buy when the **MACD line crosses above its signal line** and **RSI(14) is above 50**; stop at the nearest swing low (or ATR-based); target 1.5R or 2R. Sells are the mirror image.
- **Not one presenter's rules:** the template is generic, so the readings below are ours, fixed before any result. Where tutorials differ, we fix one reading and test at most two choices (the trend timeframe and the target). Not tested: the ATR stop, "RSI leaving oversold" instead of "above 50", and an RSI that must cross 50 on the same bar as the MACD (that would be rare).
- **Looked at before (disclosed):**
  - **Stochastic + RSI + MACD on EUR/USD** (14 Oct 2026, buried, all six versions): the same MACD cross with RSI above 50, a swing stop and a 1.5R target, plus a Stochastic arming rule, on 15-minute to 1-hour bars. Its trades won about 40% of the time. That test is the reason this one is on **NQ**, not EUR/USD: on EUR/USD it would be a near-duplicate chosen after a negative result.
  - **MACD (12, 26, 9) crossover on ES 60-minute bars** (buried); **RSI 30/70 on gold** with and without a trend filter (buried); on NQ, the 9 EMA strategy, the EMA 5/8/13 ribbon, intraday momentum, opening range breakouts and the change of character test (all buried).
  - Classic indicator combinations have therefore been tried many times on this site; that raises the bar below.

## Instrument and data
- **NQ** (E-mini Nasdaq-100 futures), `NQ_1min.csv` (NinjaTrader, back-adjusted continuous contract, 1-minute bars stamped at their close, New York clock, overnight session included), 2020-01-01 to **2026-09-25 17:00 New York**, the cut of every futures study; the exchange calendar of our other NQ tests (`rb_lib.js`) for the regular session (09:30 to 16:00) and early closes. $20 a point, tick 0.25.
- **Charts:** like the default continuous futures chart on most platforms, **all indicators are computed on continuous bars that include the overnight session** (5-minute, 15-minute and 60-minute bars on the New York clock, stamped at their close, built from the minutes that exist; the back-adjustment keeps prices continuous across rolls). **Trades are taken only in the regular session** (day trading).
- **Warm-up:** indicators are computed from the first bar of the file; **no trade before 2020-02-03**, so every average has run for several times its length.
- **Holes (rule 3):** `data_holes.json`; a trade is dropped if a known hole overlaps the span from 120 minutes before its entry to its exit, and every gate and verdict is recomputed without those trades.

## Indicators (standard settings)
- **EMA 200** of the closes of the 15-minute bars (variants -15) or of the 60-minute bars (variants -60), seeded with the simple average of the first 200 closes.
- **MACD (12, 26, 9)** on the 5-minute bars: EMA(12) - EMA(26) of the closes; signal line = EMA(9) of the MACD; EMAs seeded with the simple average of their first values.
- **RSI(14)** on the 5-minute bars, Wilder's method, seeded with the simple averages of the first 14 changes.
- **Swing low (high):** a 5-minute bar whose low is strictly below the lows of the 2 bars before and the 2 bars after it (a fractal), known at the close of the 2nd bar after.

## Rules (described for a long; a short is the mirror image)
- **Trend filter:** at the close of the 5-minute signal bar, the close of the **last completed** 15-minute (or 60-minute) bar is **above** its EMA 200. (A higher-timeframe bar is completed when its close stamp is at or before the 5-minute bar's close stamp; no look-ahead.)
- **Signal** at the close of 5-minute bar k: the **MACD line crosses above the signal line** (MACD[k] > signal[k] and MACD[k-1] <= signal[k-1]) **and RSI(14)[k] > 50**, with the trend filter long. A cross with RSI at or below 50 is not a signal.
- **Signal window:** 5-minute signal bars stamped from **09:35 to 15:30** New York (on an early-close day, up to 30 minutes before the close).
- **Entry:** at the **open of the first minute after the signal bar**, inside the session.
- **Stop:** **one tick below the nearest swing low**: the most recent swing low known at the close of the signal bar, within the last 48 five-minute bars (4 hours), whose low is below the signal bar's close. None: no trade. No trade if the entry is at or below the stop. **R** = entry to stop, in points.
- **Target:** **1.5R** (variants -1.5R) or **2R** (variants -2R) from the entry. Stop checked first inside a minute; a level a minute opens beyond fills at the open. A trade still open closes at the **session close** (the close of the last minute at or before 16:00, or the early close).
- **One position at a time;** a signal while a position is open is ignored; several trades a day are allowed. Long and short.

## Variants (the only ones tested)
**MRE-15-1.5R, MRE-15-2R, MRE-60-1.5R, MRE-60-2R** (trend timeframe x target). All long and short.

## Costs
- **$15.76 per round trip per contract** (commission $5.76 plus one tick of slippage on each fill), as in all our ES and NQ tests; also shown at 1.5x and 2.5x. Results in dollars per contract and in R.

## Periods, gates, control
- **Periods (by trade date), as in our other NQ tests:** development 2020-02-03 to 2023; validation 2024-01 to 2025-03; holdout 2025-04 to 2026-09-25 (**already used** by the earlier NQ tests).
- **Six gates per variant** (net dollars per contract): validation profit factor >= 1.2; at least 50 trades in each period; development **t >= 2.5** (four variants; classic indicator combinations have been tried many times on this 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 in all: Inconclusive.
- **Matched control (moved entries):** every real trade moved, all together, by one random circular offset of whole usable days (at least 5% of them), entered at the open of the first minute of the new day's session at or after the same time, same direction, the same stop distance in points, the same target multiple, the same session-close exit and costs; each moved trade is simulated on its own. 500 runs, seeds 1000 + run. Statistic: average net dollars per trade. It asks whether the indicator signal picks better moments than the same trades on other days.
- **Also reported (descriptive, no gates):** the win rate with its Wilson interval, set against the "80%" claim; exits by reason; median risk in points and its cost in R; trades per day; long and short; by year; by hour of entry; how many MACD-and-RSI signals the EMA 200 filter removed, and how those removed signals would have done with the same exits (does the filter help?); the "lag" question: the median distance price had already travelled from the swing low to the entry, and the median best and worst move after the entry within the trade (in R).

## Engine and self-test (before the run)
New engine `mre_lib.js` (the existing futures loader and calendar), independent re-implementation `mre_ref.js`, `mre_selftest.js` that must pass before any result is printed: the EMA, MACD and RSI against hand-worked values; the 15- and 60-minute bars and the "last completed bar" rule at their boundaries; a MACD cross with RSI above and at 50; a cross against the trend filter; the 09:35 and 15:30 limits and an early close; the swing stop (none in 48 bars, one above the close skipped, a tie); an entry at or below the stop; a signal during an open position; stop and target in one minute; the session-close exit; the reference matched trade by trade on the real data for all four variants; the control at offset 0 reproducing the real entries.

## Before the article
Results go to the owner first: all four variants, every gate, long and short, by year, the exits, the win rate against the claimed 80%, and the filter and lag descriptions. One article, published only with the owner's agreement, linked to the Stochastic + RSI + MACD and MACD crossover posts. Working title for search: "MACD + RSI Strategy Backtest: The EMA 200 Trend Filter on 6 Years of NQ".

## Reading the result
"Buried" or "Inconclusive" mean a statistically convincing edge was not demonstrated; neither is proof that none exists. One market, one data source, one standard reading of a template that comes in many versions.
