# Parabolic SAR on EURUSD, 1-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 SAR 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 ("facem Parabolic SAR?"), from the list of searched indicators not yet tested (proposed on 2026-10-21 with the warning that it is close to Supertrend, which was buried).
- **The idea:** J. Welles Wilder's Parabolic SAR ("stop and reverse", *New Concepts in Technical Trading Systems*, 1978) is a trailing stop that accelerates as a trend extends; when price touches it, the position reverses. It is drawn as dots under or over the price and is usually traded either as Wilder designed it (always in the market) or only in the direction of a trend filter.
- **Market (our choice, stated):** EURUSD, the most traded pair, on 1-hour bars, where the SAR is widely taught. One market, as in every test on this site.
- **Looked at before (disclosed):** on these EURUSD 1-hour bars, the FX study (Supertrend, MACD, Donchian and three others, all buried), the golden cross, Fibonacci 61.8%, Ichimoku, Stochastic + RSI + MACD and the ADX + DI test, all buried. Supertrend, the closest relative of the SAR, was buried on ES and in the FX study. **No SAR value has been computed on the site.**

## Instrument and data
- **EURUSD**, IC Markets MT4 demo, 1-minute bid history **2004-01-01 to 2026-09-28** (`fx_data.loadFx`), New York wall clock, close stamps; **1-hour bars** from `gh_lib.barsOf(M, 60)` as in the other EURUSD tests; incomplete bars kept, empty hours do not exist.
- **Holes (rule 3):** `data_holes_eurusd.json`; every gate and verdict is recomputed without trades open across a suspect or unclear gap.

## The indicator (Wilder's defaults: acceleration factor start 0.02, step 0.02, maximum 0.20)
- Computed on the 1-hour bars. In a rising phase, SAR(next) = SAR + AF x (EP - SAR), where EP is the highest high of the phase; AF starts at 0.02 and rises by 0.02 (to at most 0.20) each bar that makes a new EP. SAR(next) may not be above the lows of the current and the previous bar. A falling phase is the mirror (EP = lowest low; SAR not below the two latest highs).
- **Reversal:** a rising phase ends when a bar's low reaches the SAR in force for that bar; the new falling phase starts with SAR = the EP of the old phase, EP = that bar's low, AF = 0.02 (the mirror for a falling phase).
- **Start:** the first phase is rising if the second bar's close is above the first bar's, falling otherwise, with SAR = the first bar's low (high) and EP = the high (low) of the first two bars. Values are used only after a warm-up of 500 bars, so the seed has no effect.

## Rules
- **The fill is the SAR level itself, as Wilder designed it:** the SAR in force for a bar is known when that bar opens, so it is a resting stop order. Fills are found on the 1-minute bars inside the hour: the first minute whose low (for a long) or high (for a short) reaches the SAR fills at the SAR, or at that minute's open if it opens beyond it.
- **Three variants:**
  - **PS-SAR (Wilder's system):** always in the market; every reversal closes the position and opens the opposite one at the same fill.
  - **PS-200 (trend filter):** at a reversal, the new position is opened only if it agrees with the 200-bar EMA of 1-hour closes at the last completed bar (long above, short below); otherwise flat until the next reversal that agrees. A position is closed at the next reversal.
  - **PS-ADX (strength filter, Wilder's own pairing):** at a reversal, the new position is opened only if ADX(14) at the last completed bar is at least 25; a position is closed at the next reversal.
- No other stop or target. A position open at the end of the data closes at the last close.

## Costs and financing
- **1.0 pip per round trip**, as in every EURUSD test (IC Markets Raw: commission plus 0.3 pip of spread); a reversal pays two half-costs (one round trip per trade). Results at 1.5 and 2.5 times the cost are shown; the verdict is that of the base cost.
- **Swap:** not in the base result; a stress scenario charges 0.5 pip per night held (Wednesday counting three).

## Results, periods, gates, control
- **Unit:** pips per trade (net). Also reported: trades, holding time, long and short, by year, time in the market, the cost per trade against the gross.
- **Periods (by entry date):** development 2004 .. 2012; validation 2013 .. 2019; holdout 2020 .. 2026-09-28 (**already used** by earlier EURUSD tests).
- **Six gates per variant:** validation profit factor >= 1.2; at least 50 trades in each period; development **t >= 2.5** (the stricter FX bar: many variants have been tried on this pair, and the SAR is a close relative of the buried Supertrend); 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):** every real trade moved, all together, by one random circular offset of whole hourly bars (at least 5% of them), keeping its direction and its length in bars; entry and exit at the open of the first minute of the moved bars; same costs. 500 runs, seeds 1000 + run. Statistic: average net pips per trade.

## Engine and self-test (before the run)
New engine `ps_lib.js`, independent re-implementation `ps_ref.js`, `ps_selftest.js` that must pass before any result is printed: the SAR against a hand calculation (AF steps and cap, the two-bar limit, a reversal and the new phase); the fill at the level and at a gapped open inside the hour; the three variants' entry rules; the end of the data; the reference matched trade by trade on the real data for the three variants; the control at offset 0 reproducing the real trades.

## Before the article
Results go to the owner first. One article, published only with the owner's agreement. Working title for search: "Parabolic SAR Strategy Backtest: 22 Years of EUR/USD".

## Reading the result
"Buried" or "Inconclusive" mean a statistically convincing edge was not demonstrated; neither is proof that none exists. One pair, one timeframe, one broker's demo history, Wilder's default settings only.
