Backtesting with NinjaTrader takes about five clicks. Making the result mean something takes one setting that most walkthroughs skip: order fill resolution. This guide gives you the click path first, then spends the rest of its length on the assumption that setting controls, because that assumption can flip a single trade from a winner to a loser without a line of your strategy changing.
The click path for backtesting with NinjaTrader, short version
According to the vendor's own Backtest a Strategy help page, you need two things before you start: historical data and a NinjaScript strategy. Then the steps are:
- Open the Strategy Analyzer and set Backtest type to Backtest (the other options are Optimization, Walk Forward Optimization and Multi-Objective Optimization).
- Pick the strategy.
- Set the strategy parameters and the backtest properties.
- Choose the instrument and the data series: bar type, value, start date, end date and trading hours.
- Press Run.
Two notes from that same page are worth knowing up front. By default the analyzer downloads data from your market data provider, which slows big runs, and you can switch on Use local data only in the analyzer's properties to stay inside your own database. And IncludeTradeHistoryInBacktest is false by default, so fields like SystemPerformance.AllTrades.Count have no Trade objects to point at unless you turn it on in the Configure state.
That's the part every tutorial covers. Five clicks, a metrics table, done. The properties list on that page is where the real decisions hide, and the one that matters most gets a single line: Order fill resolution, with a pointer to another help section. Nothing about what the modes do or why you would choose one.
The intrabar problem: one bar, two possible histories
A bar is four prices: open, high, low, close. It does not record the order in which the high and the low printed. At standard resolution, the engine has only those four numbers per bar, so when a strategy's orders could fill anywhere inside the bar, it has to assume a sequence.
Most of the time the assumption is harmless. If your stop is far below the low and your target is far above the high, nothing gets touched and nothing is ambiguous. The trouble starts when a single bar reaches both your stop and your target.
Here is a hypothetical example. It is arithmetic on invented prices, not a result from any real strategy or market. Take a futures contract with a 0.25 tick size where one tick is worth $12.50. A five-minute bar prints:
| Open | High | Low | Close |
|---|---|---|---|
| 5000.00 | 5004.00 | 4997.00 | 5001.00 |
Your strategy buys at 5000.00 on that bar's open, with a protective stop at 4998.00 (8 ticks, $100 risk) and a profit target at 5003.00 (12 ticks, $150 reward). The bar's low of 4997.00 is below the stop. The bar's high of 5004.00 is above the target. Both orders were touched.
- Low first, then high: price dropped to the stop, you were out for −$100, and the rally afterwards never mattered.
- High first, then low: price hit the target, you banked +$150, and the later drop never mattered.
Same bar. Same strategy. A $250 swing on one contract, decided entirely by an ordering the data never recorded.
The condition that puts a strategy in this category is simple enough to check against your own system in under a minute: if your stop distance and your target distance can both be smaller than a typical bar's range, the fill assumption is choosing some of your outcomes. A swing system with 80-point stops on daily bars rarely cares. A scalper with 8-tick stops on five-minute bars cares on a meaningful share of its trades. Tight stops, tight targets, and brackets placed at the same time are the signature.
Order fill resolution: a correctness setting, not just a speed setting
The property list on the vendor page names Order fill resolution under the Historical fill processing group and sends you elsewhere for the details. One of the editorial guides that mentions it describes the high-resolution option as running five to twenty times slower. That is true as far as it goes, and it makes the setting sound like a convenience dial: faster and rougher, or slower and finer.
It is better thought of as a correctness dial. The higher resolution exists to give the engine a finer price sequence to resolve fills against, so it no longer has to guess the order of events inside a bar. The cost is run time. What you buy is a result that does not depend on an unrecorded ordering.
One caveat on sourcing: the vendor's separate page explaining the historical fill modes was not reachable when this article was prepared, so the description above is the general principle rather than a quote of that page's wording. Open the help section your Strategy Analyzer links to from Order fill resolution and read the exact mode definitions for your installed version before you rely on any specific behavior. Version differences exist, and a setting description you read in a blog post is not a substitute for the page that ships with your build.
A one-line self-test, using the example above:
Can any of my trades have both a stop and a target inside one bar? If yes, run the same strategy at standard and at high fill resolution. If the P&L moves, the standard-resolution number was an assumption, not a measurement.
If the two runs agree closely, your strategy sits outside the ambiguous category and standard resolution is fine. If they disagree, trust the finer one and treat the gap itself as information about how fragile the edge is. A strategy whose profit lives entirely in the gap between the two runs has not shown an edge. It has shown an optimistic tie-break.
Tick replay is a different switch
This is where the confusion costs people the most. Tick replay and order fill resolution sound like two names for "use tick data", and they are not the same control.
Fill resolution governs how historical order fills are resolved. Tick replay governs how a historical bar series is processed for your indicator and strategy logic, which matters for code that calculates on every tick rather than on bar close. Its job is narrow: making a calculate-on-each-tick indicator behave on history the way it behaves live.
Turning on tick replay does not, by itself, settle the intrabar fill question, and turning up fill resolution does not make an every-tick indicator recalculate the way it does in real time. People flip one, see a changed result, and conclude the other is handled. Record both settings separately. If you want the broader background on why bar data and tick data disagree, the tick data versus bar data glossary entry covers the underlying difference.
Slippage and commission: both start at zero
The properties page states the slippage default plainly: the number of ticks applied to market, stop market and market-if-touched executions, with a default of 0. Commission is controlled separately by Include commission and the commission templates attached to your account. Out of the box, a fresh backtest therefore trades in a frictionless world.
The effect is easy to underestimate until you work the numbers. Use the same hypothetical contract ($12.50 per tick) and a strategy whose average winning trade is 6 ticks, which is $75 gross per contract.
Suppose you set slippage to 2 ticks. The documentation says it applies to market-type orders, so the exact damage depends on how your orders exit:
- Market entry, stop-market exit: 2 ticks on each side, 4 ticks round trip, $50. Your 6-tick average becomes 2 ticks, or $25. Two-thirds of the edge is gone.
- Market entry, limit-order target: 2 ticks on the entry only, $25. Your 6 ticks becomes 4. A third of the edge is gone.
Now add commission. As a placeholder, say $2.00 per side, $4.00 round trip. That is another 0.32 ticks. In the stop-exit case your remaining 2 ticks ($25) drops to $21 a contract. Neither figure is a recommendation. They're placeholders chosen to show the shape: when the average trade is a handful of ticks, friction measured in single ticks is not a rounding error. It is most of the result.
The same arithmetic runs the other direction for slower strategies. With a 60-tick average trade, 4 ticks of friction costs about 7%, which a real edge can survive. So the useful question to ask of any backtest is not "did I include costs?" but "what fraction of my gross average trade do my costs consume?" Above roughly a third, treat the system as untested until you've stress-tested the friction assumption itself. The slippage glossary entry breaks down where those ticks come from in live fills.
Limit orders and the touch question
The properties list also includes Fill limit orders on touch, described as turning on or off the filling of limit orders on a single touch of price. Think about what that means for the fill model. A limit order sitting at a price that the market touched but did not trade through may or may not have been filled in real life, because your order was one of many at that level and queue position decides who gets filled, the same touch-versus-trade-through gap behind a breakout rule that needs a close.
Fill on touch is the optimistic reading: price reached you, so you got filled. A stricter setting requires price to trade through the level. If your strategy depends on limit entries at support or limit targets at resistance, flip this setting and rerun. The change in trade count and P&L tells you how much of the result relied on getting filled at the exact edge of the market.
Bars required to trade and the silent short sample
Bars required to trade sets the minimum number of bars that must exist before the strategy can submit orders. It exists so indicators have warm-up history. It also quietly shortens your test.
Take a strategy that uses a 200-bar moving average and sets bars required to 200, running on daily bars. Daily futures bars come at roughly 21 per month, so those 200 bars are about nine to ten months in which the strategy cannot trade at all. If your date range is two years, you have just cut the tradeable sample to about fourteen months and the report will not tell you that. The trade count looks plausible and the equity curve looks normal.
Two checks cost nothing. Compare the date of the first trade in the trade list against your start date. Then confirm that the bars-required value is not larger than your longest indicator lookback, because a value that is too large wastes sample and one that is too small lets the strategy trade on unconverged indicator values.
Backtest, market replay and live are three different questions
A historical backtest asks: given recorded bars and an assumed fill model, what would this logic have done? Market replay re-runs recorded market activity through a more live-like path, so it exercises timing and order handling that bar-based processing cannot. Live trading adds the rest: queue position, rejected orders, partial fills, latency and your own behavior.
The vendor page itself warns to expect some difference between real-time and backtest results, especially on less common bar types such as Point & Figure and Renko. The practical ladder is to backtest, then replay, then trade small live, and to read each step's disagreement with the previous one as a measurement of how much the earlier step was assuming.
A result that only survives in the analyzer is a flag, not a finding. If a strategy holds up at standard fill resolution and collapses under replay, the analyzer was supplying fills that the market would not have. That gap is the same one described in why backtests and live trading results diverge, and it is easier to diagnose when you can say which setting produced it.
Optimization and walk-forward: the top row is a biased estimate
The Strategy Analyzer will happily run an optimization over a parameter grid and sort the results. The top row looks like the answer. It is not, for a statistical reason rather than a software one: if you test 100 parameter combinations, the best of them has been selected partly for fitting noise in that particular history. The winner's backtest return is an upward-biased estimate of what it will do next. More combinations means more bias. This is the core of what the overfitting entry in the glossary describes.
A plateau check turns "looks stable by eye" into something you can write down:
- Take the winning parameter set and note its objective value, for example net profit or profit factor.
- Move each parameter one grid step up and one step down, holding the others fixed.
- Record the objective at every neighbor.
- Decide the rule before looking, for instance that every neighbor must keep at least 70% of the winner's objective value and stay profitable.
The 70% figure is an illustrative rule, not a standard. What matters is that the rule exists in writing before you see the neighbors. A peak that falls off a cliff one step away is a spike fitted to noise. A broad shelf where neighbors perform similarly is a parameter region, and a region is far more likely to survive contact with new data.
Walk-forward optimization goes one step further by optimizing on one window, testing on the next unseen window, then sliding forward. Its output is a series of out-of-sample segments stitched together, and that stitched curve is the only honest one the optimizer produces. The walk-forward testing entry explains the window mechanics. Fill resolution matters here too: run the walk-forward at the resolution you believe in, because a fast, optimistic resolution during the search and a strict one afterwards will make the out-of-sample segments look worse for reasons that have nothing to do with overfitting.
The settings to record next to any NinjaTrader result
A backtest result without its settings is a number nobody else can reproduce. Before you save, screenshot, or share any result, write down this list beside it:
- Order fill resolution (standard or high) and your installed version
- Fill limit orders on touch (on or off)
- Slippage in ticks, and which order types it applied to
- Commission template and per-side amount
- Bars required to trade and the date of the first actual trade
- Tick replay on or off, kept separate from fill resolution
- Data series: instrument, bar type and value, trading hours template, Break at EOD
- Date range and whether Use local data only was on
- Optimization context: how many combinations were searched, and whether the result is in-sample or out-of-sample
This is the methodology note that turns a screenshot into evidence. If you're building a wider pre-deployment routine, the stress-testing checklist picks up where this one stops. And if you run NinjaTrader alongside charting software, the NinjaTrader and TradingView integration breakdown covers a separate set of failure points.
One more reminder about what any of this proves. Historical simulation describes how a rule behaved on past data under stated assumptions. It does not forecast anything. The U.S. Securities and Exchange Commission's investor education site, Investor.gov, and the self-regulatory body FINRA both publish general guidance reminding investors that past performance does not guarantee future results, and that applies to simulated performance too. Quantzee builds analytical software, not advice, so treat everything here as method rather than a recommendation to trade anything.
