PatternX feature

Backtesting and the Optimization Lab

By the PatternX team · Published

Backtesting

PatternX backtesting replays the same 20-pattern engine bar by bar over up to 1,500 recent candles, charges fees, slippage and funding, and reports results with an in-sample/out-of-sample split and a Monte Carlo check. It is for traders who want to test settings before risking money. Starter gets basic backtests; Pro and Elite get the full version plus the Optimization Lab.

Availability: Starter (basic); Pro and Elite (full, plus the Optimization Lab); not included on Free

What a backtest simulates

A PatternX backtest replays the live pattern engine over history, one bar at a time. After 120 warm-up bars, each bar is treated as the present: the detectors look for a breakout, setups are scored, and qualifying signals become simulated trades. You can run it in PatternX Classic mode or, on Pro and Elite, in PatternX AI mode.

What you can set (defaults in brackets):

  • 1–5 venues and 1–20 symbols, with any timeframes and patterns;
  • the most recent 200–1,500 candles (1,000);
  • take-profit (10%) and stop-loss (5%);
  • minimum confidence (65), risk per trade (1%) and leverage (3);
  • starting balance ($10,000) and long/short toggles.

Costs built into every test

  • Entry: the signal bar's closing price plus 0.03% slippage.
  • Exits: at the stop or target, 0.03% worse.
  • Same-bar ambiguity: if one bar touches both stop and target, the stop is assumed to have hit first.
  • Fees: 0.05% per side.
  • Funding: 0.01% per 8 hours, always applied.
  • Liquidation and loose ends: a liquidation check runs, and trades still open at the end are closed at the last closing price.

For example, a hypothetical long entered at $100.00 with the default 10% target fills at $100.03 and, if the target is reached, exits around $109.97. Fees take roughly another $0.10 and a day of funding about $0.03, so the 10% move books as roughly 9.8%. A loser goes the other way: the same costs turn a 5% stop into a loss of roughly 5.2%. Small per trade, these costs add up across hundreds of trades.

What you get back

The report shows win rate, profit factor, net P&L, maximum drawdown, average win and loss and the equity curve, broken down by pattern, timeframe, exchange, symbol, side and market regime. It adds Sharpe and Sortino ratios, expectancy, CAGR, holding time, drawdown duration, the longest losing streak, time in market and a buy-and-hold benchmark. A test with fewer than 30 trades carries a warning, and you can add an optional write-up generated by a language model.

In-sample, out-of-sample and Monte Carlo

Every result is split in two: the first 70% of the period is in-sample, the last 30% out-of-sample. If a configuration shines in the first part and falls apart in the second, it has probably been fitted to noise.

A Monte Carlo check then reshuffles the order of the trades 400 times and reports the 5th-percentile, median and 95th-percentile return, plus the 95th-percentile drawdown. The same trades in a different order can produce a very different path, so that drawdown figure is a more sober planning number than the single historical one.

The Optimization Lab

On Pro and Elite, the Optimization Lab runs a grid over take-profit × stop-loss × minimum confidence, up to 12 variants: for example 2 targets × 3 stops × 2 confidence levels. Instead of crowning the highest raw profit, it ranks variants with a robustness formula weighted toward out-of-sample and Monte Carlo results. A common mistake is to ignore that ranking and pick whichever variant earned most in-sample.

Plan limits

PlanBacktesting
FreeNot included
StarterBasic: 1 venue, 3 symbols, 2 timeframes
ProFull, with AI mode and the Optimization Lab
EliteFull, with AI mode and the Optimization Lab

Prices are on the pricing page. Momentum Lab has its own, separate backtester for its premarket strategies, on Elite.

A sensible workflow

  1. Start with the defaults on enough symbols and candles to produce at least 30 trades.
  2. Compare out-of-sample with in-sample before you look at total profit.
  3. Ask whether you could sit through the Monte Carlo 95th-percentile drawdown.
  4. On Pro or Elite, let the Optimization Lab compare variants, and favour its robustness ranking.
  5. Paper-trade the chosen settings before going live (automation).

What a backtest can't tell you

  • Market context is neutral: liquidity, spread, order-book, funding-rate and 24-hour volume inputs don't vary, so those filters are effectively off (the funding cost above is still charged).
  • There is no higher-timeframe or historical win-rate input, so scores differ from live ones.
  • Each series holds one position at a time, sizing is fixed (no compounding), and take-profit and stop-loss are price percentages only.
  • The risk engine, trailing stops, break-even, approval delays and partial fills aren't modelled.

A backtest is evidence about the past under simplified conditions, not a forecast. The backtesting methodology and the backtesting glossary entry go further.

Frequently asked questions

Why don't my backtest results match my live trades?

Live trading includes things the replay leaves out, such as real spread and order-book conditions, the higher-timeframe check, risk-engine blocks, approval delays and partial fills. Expect a gap, and treat a large one as a reason to investigate before trading bigger.

How many trades does a backtest need?

PatternX warns below 30 trades, because a handful of trades can make almost any setting look good or bad by chance. Adding symbols, timeframes or candles is the usual way to raise the count.

Can I backtest in PatternX AI mode?

Yes, on Pro and Elite. The replay uses the same neutral market context in AI mode as in Classic, so read AI-mode results with the same caution.

Does the Optimization Lab find the most profitable settings?

It deliberately doesn't rank on raw profit; it favours variants that hold up out-of-sample and across Monte Carlo reshuffles. Even the top-ranked variant is a candidate to paper-trade, not a finished strategy.

Is backtesting included on the Free plan?

No. Basic backtesting starts on Starter at $69 a month; Pro at $119 and Elite at $299 get the full version with the Optimization Lab.

Related reading

Educational content, not financial advice. Chart patterns describe probabilities, not certainties; trading — especially with leverage or outside regular hours — can lose money, including more than you expect. See the risk disclaimer.