Backtest Spec — Reversal-Pattern Entry Strategies

Phase C: Reversal-pattern entries with structural stop-loss and reward/risk optimization.


1. Purpose & Hypothesis

Prior phases established a reliable screening universe (v5.1 optimized filter) and validated momentum-based entry signals. This phase tests whether price-action reversal patterns at key structural levels produce higher expectancy and better risk-adjusted returns than the baseline entry configs already identified.

Hypothesis: Reversal entries timed to pattern completion, combined with structure-derived stop-losses, will deliver profit factor ≥ 1.8 and expectancy ≥ 0.5R across the screened universe, with materially lower max drawdown than momentum entries.


2. Universe & Fixed Screening Basis

  • Filter: v5.1 optimized filter (unchanged from Phase B).
  • Timeframe: Daily bars.
  • Instrument pool: US equities passing the v5.1 screen on each bar date.
  • Data period: Same lookback used in Phase B (minimum 5 years of daily history).
  • No changes to the screener in this phase — the filter is a controlled variable.

3. Candidate Entry Patterns

3.1 Primary (must test)

PatternDefinition (simplified)
Bullish EngulfingCurrent bar body fully engulfs prior bar body; close > prior close; occurs after a defined down-move.
Outside ReversalCurrent bar high > prior high AND low < prior low; close in upper quartile of range; prior trend down.
2B Bottom (spring)Price undercuts a prior swing low then closes back above it within 1–2 bars.
3-Bar Flush & Snap≥ 3 consecutive down bars followed by a bar that closes above the prior bar’s high.

3.2 Secondary (optional / lower priority)

  • Hammer / pin bar at support
  • Morning star (3-candle)
  • Exhaustion gap reversal
  • Inside bar breakout after flush

Secondary patterns are stretch goals — run only if primary results warrant expansion.


4. Entry Configuration (Fixed from Prior Research)

Carry forward the best-performing entry timing from Phase B:

  • Entry trigger: Next-bar open after pattern completion bar closes.
  • Position sizing: Fixed fractional (1% risk per trade) — same as Phase B baseline.
  • Max concurrent positions: Carry forward Phase B cap.

These are constants; do not re-optimize entry timing in this phase.


5. Stop-Loss Test Matrix

Test each pattern × each stop-loss variant:

IDStop-Loss VariantDescription
SL-1Pattern low (intraday)Stop at the lowest low of the pattern bars.
SL-2Close-basedStop triggers only on a daily close below the pattern low.
SL-3Fixed -1%Stop at entry price − 1%.
SL-4Fixed -2%Stop at entry price − 2%.
SL-5ATR bufferStop at pattern low − 0.5 × ATR(14).
SL-6Swing lowStop at the most recent higher-timeframe swing low (e.g., 20-bar lookback).

Total stop-loss configs per pattern: 6.


6. Exit / Take-Profit Test Matrix

For each (pattern, stop-loss) pair, test:

IDExit VariantDescription
TP-12R fixedExit full position at 2× initial risk.
TP-23R fixedExit full position at 3× initial risk.
TP-35R fixedExit full position at 5× initial risk.
TP-4Partial + runnerExit 50% at 2R; trail remainder with 1.5 ATR trailing stop.
TP-5Trailing stop onlyNo fixed TP; trail with 2 ATR from highest close.
TP-6Structure breakExit on first daily close below the most recent swing low after entry.
TP-7Wide TP (10R)Stress-test for outlier capture; exit at 10R or time stop (40 bars).

Total exit configs per (pattern, stop-loss) pair: 7.

Full test matrix size: 4 patterns × 6 SL × 7 TP = 168 configurations (primary patterns only).


7. Evaluation Metrics

Every configuration must report:

MetricNotes
Profit FactorGross profit / gross loss
Expectancy (R)Mean R-multiple per trade
Avg Win / Avg LossIn both $ and R terms
Win Rate% of trades closed in profit
Sharpe RatioAnnualized, using daily equity curve
Total ReturnCumulative % over test period
Max DrawdownPeak-to-trough on equity curve (% and $)
Total TradesMust be ≥ 30 for statistical relevance
Avg Bars in TradeTime exposure

Rank configs by expectancy × √(total trades) as the primary sort, with profit factor and max DD as tiebreakers.


8. Persistence & Output Requirements

8.1 Mandatory artifacts for every tested config

  1. Summary report — one row per config with all metrics from §7.
  2. Config-level detail — parameters, pattern definition hash, SL/TP IDs.
  3. Full trade log — every individual trade: entry date, exit date, entry price, exit price, stop price, target price, R-multiple, P&L, bars held, pattern ID, ticker.

Non-negotiable: Full trade-by-trade output must be saved for every tested configuration. No config may be evaluated on summary stats alone.

8.2 File formats

  • Summary report: CSV (machine-readable) + rendered markdown table for review.
  • Config detail: JSON (one file per run, or single JSON array).
  • Trade logs: CSV (one file per config, or one combined CSV with a config ID column).
  • Optionally export an XLSX workbook with sheets: summary, config detail, and a sheet per top-10 config trade log.

8.3 Naming & folder conventions

results/
  phase-c-reversal/
    summary_report.csv
    summary_report.md
    configs/
      config_{PATTERN}_{SL-ID}_{TP-ID}.json
    trades/
      trades_{PATTERN}_{SL-ID}_{TP-ID}.csv
    (optional) phase-c-reversal-workbook.xlsx

Filenames must be lowercase, hyphen-separated, and include the pattern short name, SL-ID, and TP-ID so any file can be traced to its config without opening it.


9. Open Questions & Future Extensions

  • Combination entries: Layer reversal pattern + volume spike or RSI divergence as confirmation. Defer to Phase D if primary results are promising.
  • Multi-timeframe: Test pattern on weekly with entry refined on daily.
  • Regime filter: Overlay a broad-market regime filter (e.g., index above 200 SMA) to suppress entries in downtrends.
  • Sector rotation: Does pattern performance cluster by sector? Add sector tag to trade log for post-hoc analysis.
  • Adaptive stops: Volatility-scaled stops that blend ATR with pattern structure — explore if fixed variants underperform.
  • Short-side mirror: Mirror all patterns for bearish reversals / short entries in a future phase.

10. Execution Checklist

  • Confirm v5.1 filter code is locked and tagged.
  • Implement pattern detectors (§3.1) with unit tests on known examples.
  • Build SL/TP engine that accepts config IDs from §5–§6.
  • Run full 168-config matrix.
  • Persist all artifacts per §8.
  • Generate summary report and rank table.
  • Review top-10 configs: inspect trade logs for data artifacts or curve-fitting.
  • Write Phase C completion report with findings and recommended next phase.